dev-master
9999999-dev https://github.com/PeterNotenboom/EppXml-2-ArrayXML/EPP to a simple readable array, including Namespace and CDATA support
MIT
The Requires
- php >=5.3.0
The Development Requires
xml array epp
XML/EPP to a simple readable array, including Namespace and CDATA support
An EPP (http://en.wikipedia.org/wiki/Extensible_Provisioning_Protocol), with Namespace support, to a simple Array. Still usable for normal XML too. CDATA is supported., (*1)
For regular XML you can use this (probably) fine:, (*2)
$xml = simplexml_load_string($xmlstring); $json = json_encode($xml); $array = json_decode($json,TRUE);
But it doesn't work "out of the box" with namespaces. Also, simplexml_load_string somehow removes certain attributes. For example, if your EPP had:, (*3)
<domain:contact type="billing">P-ABC120</domain:contact>
It will remove the "type" attribute. And for EPP any missing information makes those methods unusable., (*4)
First, load the XML:, (*5)
PN\Xml2Array::loadXML($xml_string); //or PN\Xml2Array::loadXML(file_get_contents('somefile.xml'));
Get the whole array from your complete EPP string:, (*6)
print_r( PN\Xml2Array::getArray() );
Get all the Namespace prefixes + URI's as an array:, (*7)
print_r( PN\Xml2Array::getNamespaces() );
Get a part of the EPP in array by giving the prefix:, (*8)
print_r( PN\Xml2Array::getArrayNS('contact') );
Too lazy to look where in the array/xml a tag is? Or the tag could be changing in different xml files? See example1.php, use it like this:, (*9)
print_r( PN\Xml2Array::getArrayElement('domain', 'pw', true ) );
Want to get an attribute like:, (*10)
<result code="1000">...
See example1.php, use it like this:, (*11)
print_r( Xml2Array::getArrayAttribute(null, 'result', 'code', true) );
Simple as that., (*12)
MIT, (*13)
XML/EPP to a simple readable array, including Namespace and CDATA support
MIT
xml array epp