I'm having some headaches with parsing xml file, the problem regards xml with hex entities inside of the xml file (i.e: à and so on), I cannot believe why but the result of parsing outputs strange chars and not preserve these entities.
xml text example:
<?xml version="1.0" encoding="iso-8859-1"?>
<root version="0.9.0">
<xmlnode TEXT="test one">
<xmlnode TEXT="this works good"/>
</xmlnode>
<xmlnode TEXT="I put some decimal entities inside a subnode">
<xmlnode TEXT="E' una prova "RIDUZIONE". Se è inserita una riduzione questa deve essere applicata al calcolo."/>
<xmlnode TEXT="è già tutto implementato"/>
<xmlnode TEXT="Controllare perchè non funziona più"/>
</xmlnode>
The (pseudo)code is simple:
- xmlobj = new DOMDocument('1.0', 'UTF-8'); (I tried to put different options to the DOMDocument Object)
- $xmlobj->load($source); (where source has the path of the xml file)
- $XPathobj = new DOMXPath($xmlobj);
- $XPathobj->query($query); (where query is a normal xpath query string)
- ciclying to the DOMNodeList for DOMElement e outputs something
I tried also with the class here (you can use this source file to test):
phpclasses.org/package/5667-PHP-Par
...
I have the same output -> Parsing doesn't preserve the entities and when output data I have strange chars and not entities anymore.
I tried a lot but I cannot find a solution, please help me.
Thanks