ID: 46307 Updated by: [EMAIL PROTECTED] Reported By: phpbugs at lange dot nom dot fr -Status: Open +Status: Bogus Bug Type: XML related Operating System: GNU/Linux, Fedora Release 9 PHP Version: 5.2.6 New Comment:
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. Duplicate of bug #45996 Previous Comments: ------------------------------------------------------------------------ [2008-10-15 19:52:41] phpbugs at lange dot nom dot fr Description: ------------ It may be a misunderstanding of mine, but xml_parse doesn't seem to resolve 'simple' entities like < > or &. According to the doc, and one other bug report, I think it should. While other parsers (XMLReader, SimpleXML, DOM, ...) do. In numerical form, it does work (>). I tested with libxml2 versions 2.7.1 and 2.7.2, and expat 2.0.1. I found this when doing SOAP calls, I couldn't pass the value "<" to a PHP SOAP server (which is using NuSOAP). I don't have a workaround for the moment. Reproduce code: --------------- function character_data($parser, $data){ print("character_data: $data\n"); } function parsestring( $strg ) { $parser = xml_parser_create("UTF-8"); xml_set_character_data_handler($parser,'character_data'); xml_parse($parser,$strg,true); xml_parser_free($parser); $reader = new XMLReader(); $reader->XML( $strg ); while( $reader->read() ) { if( $reader->value ) print( $reader->name . ": " . $reader->value . "\n"); } } $xmlcdata = "<element><![CDATA[A>B&C<D]]></element>"; $xmlescaped = "<element>A>B&C<D</element>"; $xmlnumeric = "<element>A>B&C<D</element>"; print("parsing $xmlcdata \n"); parsestring( $xmlcdata ); print("\nparsing $xmlescaped \n"); parsestring( $xmlescaped ); print("\nparsing $xmlnumeric \n"); parsestring( $xmlnumeric ); Expected result: ---------------- parsing <element><![CDATA[A>B&C<D]]></element> character_data: A>B&C<D #cdata-section: A>B&C<D parsing <element>A>B&C<D</element> character_data: A character_data: > character_data: B character_data: & character_data: C character_data: < character_data: D #text: A>B&C<D parsing <element>A>B&C<D</element> character_data: A character_data: > character_data: B character_data: & character_data: C character_data: < character_data: D #text: A>B&C<D Actual result: -------------- parsing <element><![CDATA[A>B&C<D]]></element> character_data: A>B&C<D #cdata-section: A>B&C<D parsing <element>A>B&C<D</element> character_data: A character_data: B character_data: C character_data: D #text: A>B&C<D parsing <element>A>B&C<D</element> character_data: A character_data: > character_data: B character_data: & character_data: C character_data: < character_data: D #text: A>B&C<D ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46307&edit=1