xml pasing problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
henkha
Forum Newbie
Posts: 4
Joined: Wed Sep 19, 2007 11:06 pm

xml pasing problems

Post by henkha »

Hi,

For a while now i started working with php, but have run into a big problem.
we communicate from windows to php trhough some scripts an i pass a xml document to a php page for processing
but as soon as there are any special char like the english pound sign or ascci code 215
the following code fails

Code: Select all

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startTag", "endTag");
 xml_set_character_data_handler($xml_parser, "contents");
if(!(xml_parse($xml_parser, $data, feof($fp)))){
       die(error_base_xml(20000,"could not parse the xml structure","Error on line " . xml_get_current_line_number($xml_parser)));
It is unable to parse the xml as for the microsoft msxml parser who created the xml there is no problem
aso the code gives me a error
<br />
<b>Warning</b>: feof(): supplied argument is not a valid stream resource in <b>D:\websites\HomeOrderTest\xml_parser.php</b> on line <b>169</b><br />

anyone has an idea why this is failing
ReDucTor
Forum Commoner
Posts: 90
Joined: Thu Aug 15, 2002 6:13 am

Post by ReDucTor »

int xml_parse ( resource $parser, string $data [, bool $is_final] )
Where is $fp set? Or is $data already containing all the data?

If so you need

Code: Select all

if(!xml_parse($xml_parser, $data, true)) {
henkha
Forum Newbie
Posts: 4
Joined: Wed Sep 19, 2007 11:06 pm

extra information about xml that fails

Post by henkha »

Also things like the bellow xml fails when trying to parse it

<STRING>
<ORIGINAL>"Add New Page"</ORIGINAL>
<TRANSLATION>"Neue Seite hinzufügen"</TRANSLATION>
<TRANSLATION>"新しいページを追加"</TRANSLATION>
</STRING>
henkha
Forum Newbie
Posts: 4
Joined: Wed Sep 19, 2007 11:06 pm

php warning

Post by henkha »

Yes $data contains the whole xml and after changing the function to pass true the message was gone
thanks for that :)

The only problem thats left is the special characters

I hope someone has a idea on that one as i just can not get it to work
Post Reply