Convert from XML to array, array to XML, based on libs from lalit.org
Convert XML to an array representation, and then convert back to XML again., (*1)
Drop-in replacement for Lalit.org's XML2Array and Array2XML classes, based on their work., (*2)
$array = XML2Array::createArray($xml); $xml = Array2XML::createXML($array);
Note that there's no need to specify the 'rootNode' parameter from the previous implementation. If the array contains a single root item, that will automatically be used as the root node., (*3)
Of course, if you need a drop-in replacement, the old syntax works as before., (*4)
$array = XML2Array::createArray($xml); $xml = Array2XML::createXML('rootNode', $array);
$config = array( 'useNamespaces' => true, ); $array = XML2Array::createArray($xml, $config);
$config = array( 'attributesKey' => '$attributes', 'cdataKey' => '$cdata', 'valueKey' => '$value', ); $array = XML2Array::createArray($xml, $config); $xml = Array2XML::createXML($array, $config);
Original XML2Array and Array2XML libraries from Lalit.org, (*5)