public static function Braintree_Xml_Parser::arrayFromXml in Commerce Braintree 7
sets up the SimpleXMLIterator and starts the parsing @access public
Parameters
string $xml:
Return value
array array mapped to the passed xml
1 call to Braintree_Xml_Parser::arrayFromXml()
- Braintree_Xml::buildArrayFromXml in braintree_php/
lib/ Braintree/ Xml.php
File
- braintree_php/
lib/ Braintree/ Xml/ Parser.php, line 27
Class
- Braintree_Xml_Parser
- Parses incoming Xml into arrays using PHP's built-in SimpleXML, and its extension via Iterator, SimpleXMLIterator
Code
public static function arrayFromXml($xml) {
// SimpleXML provides the root information on construct
$iterator = new SimpleXMLIterator($xml);
$xmlRoot = Braintree_Util::delimiterToCamelCase($iterator
->getName());
$type = $iterator
->attributes()->type;
self::$_xmlRoot = $iterator
->getName();
self::$_responseType = $type;
// return the mapped array with the root element as the header
return array(
$xmlRoot => self::_iteratorToArray($iterator),
);
}