im tying to parse an xml-file via php.
i have a list of entities in an external file ( <!ENTITY ....> )
the IE 5.something displays the xml correctly.
my script (like in the php-manual) does not.
i need to get an output of cdata mixed with entities (from xml).
the thing i dont understand:
why does the xml-parser passes entities (&xxx;) to the default-handler?
im a little bit confused, so is my question, i know.
should'nt the parser translate the entities like they are defined in xml?
XML external entities
Moderator: General Moderators
Huh, may be someone have answer why.
I worked with XML files with German special chrasters (umlauts) and XML data comes with entities. PHP(Expat) parser always stop parse this data when find & in XML data.
With this:
I solved problem. May be this is wrong, may be this is hard way, but this works for me.
I worked with XML files with German special chrasters (umlauts) and XML data comes with entities. PHP(Expat) parser always stop parse this data when find & in XML data.
With this:
Code: Select all
$xml_data = implode ('',@file($file));
$xml_data = preg_replace ('/ü/', chr(252), $xml_data);
$xml_data = preg_replace ('/ö/', chr(246), $xml_data);
$xml_data = preg_replace ('/ä/', chr(228), $xml_data);
$xml_data = preg_replace ('/ë/', chr(235), $xml_data);
$xml_data = preg_replace ('/Ü/', chr(220), $xml_data);
$xml_data = preg_replace ('/Ö/', chr(214), $xml_data);