[thelist] any XML experts? (using PHP xml_parse())

Tom Dell'Aringa pixelmech at yahoo.com
Wed Jan 1 10:51:01 CST 2003


I'm getting a strange error from xml_parse() on my xml data. I have
this xml data:

------
<?xml version="1.0"?>
<XTE>
<Response type="Product" txnid="pm01"
timestamp="2003-01-01T16:45:00Z">
<Outcome>Success</Outcome>
<Product>
<Description/>
<Price>45.36</Price>
<ProductName>Kiddush Cup #1052</ProductName>
<ProductNo>117</ProductNo>
</Product>
</Response>
</XTE>
------

Which seems to be well-formed. The problem is, when xml_parse() is
finished parsing the data, it gives me the following error:

XML error: junk after document element at line 12

I've checked this file online with other xml validators and it seems
fine, there is nothing after the closing element. I can only assume
'document element' means the last element. This seems to me to be a
peculiarity with php and xml_parse().

My parse code is this:
------
while($data)
{
   xml_parse($xml_parser, $data, false)
     or die(sprintf("XML error: %s at line %d",
      xml_error_string(xml_get_error_code($xml_parser)),
      xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
-------

Is there maybe another option besides die() that I can use here? If I
could stop PHP from erroring on this I would be fine. Not the best
solution, removing your error checking but I can't find out why this
is throwing an error on a valid file...

Tom



=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the thelist mailing list