-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export XML to array() or stdClass objects #28
Comments
Or perhaps I should use PEAR::XML_Serializer ? |
How would namespaces be treated in the expected output? E.g.
|
To convert a XML into a ARRAY is easy $sxml = simplexml_load_string($xmlcontent);
$array = json_decode(json_encode($sxml), true); With this we get the array that represents the XML. But FluidXML does not do the reverse, becose the structure of the attributes does not follow the same rule, in the case of SimpleXML the attributes are created in this way: 'infNFe' => [
'@attributes' => [
'Id' => 'NFe35150258716523000119550000000344891840634422',
'versao' => '2.00'
], NOTE: this is easily to correct! 'det' => [ 0 => [ others tag for det node 0],
1 => [ others tag for det node 1], In FluidXML this tag 'det' after 0 is ignored and puts all nodes in first 'det', i dont know correct this All xml with which I read are big and we can say a little complex see in sped-nfe |
@alepeino As far as I can tell, there's no special notation for namespaces. So maybe we can reuse the attribute notation:
|
@denormalizer Namespaces are special in that I'm not saying it's not doable, but it may be not as straightforward as one may think. |
Sorry I didn't see your namespaces in the child nodes. For simplicity, I suggest the following:
That means the translator is namespace agnostic. It is up to the user to generate the correct format. |
My Working implementation using XML_Unserialize (http://pear.php.net/package/XML_Serializer/) Where
|
It would be nice to be able to export to arrays or stdClass Objects
eg.
Would like to hear if this could be implemented.
Thanks
The text was updated successfully, but these errors were encountered: