PHP Classes

Xml parsing (decimal entities)

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  Xml parsing (decimal entities)  
Subject:Xml parsing (decimal entities)
Summary:Xml parsing problem with decimal entities inside the xml content
Messages:2
Author:Gabriele Guidi
Date:2010-08-17 11:21:15
Update:2010-08-25 20:52:49
 

  1. Xml parsing (decimal entities)   Reply   Report abuse  
Picture of Gabriele Guidi Gabriele Guidi - 2010-08-17 11:25:09
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&apos; una prova &quot;RIDUZIONE&quot;. Se &#xe8; inserita una riduzione questa deve essere applicata al calcolo."/>
<xmlnode TEXT="&#xe8; gi&#xe0; tutto implementato"/>
<xmlnode TEXT="Controllare perch&#xe8; non funziona pi&#xf9;"/>
</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

There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.