Page 1 of 1

special char parsing in xml

Posted: Thu Sep 20, 2007 7:32 pm
by henkha
I have a problem with the following

Code: Select all

$data = "<STRING> 
<ORIGINAL>Add New Page</ORIGINAL> 
<TRANSLATION>Neue Seite hinzufügen</TRANSLATION> 
<TRANSLATION>&#26032;&#12375;&#12356;&#12506;&#12540;&#12472;&#12434;&#36861;&#21152;</TRANSLATION> 
</STRING>";
if(!(xml_parse($xml_parser, $data, true))){
   die(error_base_xml(20000,"could not parse the xml structure","Error on line " . xml_get_current_line_number($xml_parser)));
}
the function will give a parser error
Does anyone know how to resolve this problem
The XML gets posted to the page though a windows application what is using msxl parser what has no problems with these special characters

Made a slight change to the message as for some reason there were " in the string

it fails on ü or the english pound key, japenees characters etc

Posted: Thu Sep 20, 2007 7:39 pm
by volka
A double-quoted string starts with the first " and ends with the next " (unless it's marked via \ )
Therefore php sees the string "<STRING>
<ORIGINAL>" followed by the unknown keyword Add -> syntax error.
try e.g.

Code: Select all

$data = <<< eox
<STRING>
<ORIGINAL>"Add New Page"</ORIGINAL>
<TRANSLATION>"Neue Seite hinzufügen"</TRANSLATION>
<TRANSLATION>"&#26032;&#12375;&#12356;&#12506;&#12540;&#12472;&#12434;&#36861;&#21152;"</TRANSLATION>
</STRING>
eox;
instead.