Page 1 of 1

XML external entities

Posted: Fri Nov 08, 2002 7:56 am
by julius_h
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?

Posted: Fri Nov 08, 2002 1:11 pm
by PaTTeR
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:

Code: Select all

$xml_data = implode ('',@file($file));

  $xml_data = preg_replace ('/&#252;/', chr(252), $xml_data);
  $xml_data = preg_replace ('/&#246;/', chr(246), $xml_data);
  $xml_data = preg_replace ('/&#228;/', chr(228), $xml_data);
  $xml_data = preg_replace ('/&#235;/', chr(235), $xml_data);
  $xml_data = preg_replace ('/&#220;/', chr(220), $xml_data);
  $xml_data = preg_replace ('/&#214;/', chr(214), $xml_data);
I solved problem. May be this is wrong, may be this is hard way, but this works for me.