I need help with parsing XML. I put an XML doc into a hidden input for an HTML FORM...
--------------
<html>
<head>
<title>TEST TEST</title>
</head>
<body>
<form method=POST action="http://nflnfl.com/mash.php">
<input type=SUBMIT>
<input type=hidden name=xdoc value='<?xml version="1.0" encoding="UTF-8" ?>
<!--OPN 2001 Proof Of Concept-->
<ScannerData>
<Device>0000000000002561</Device>
<UploadDate>3/6/2008 3:49:09 PM</UploadDate>
<BarCode>
<Symbol>8</Symbol>
<Data>779502944821</Data>
</BarCode>
etc.

--------------
The PHP page includes...

--------------

$data = $_POST;
if (!xml_parse($xml_parser, $data, TRUE))
die(sprintf("XML error: %s at line %d column %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser),
xml_get_current_column_number($xml_parser)));

--------------

This works fine on my Windows Vista/Apache 2.2/PHP 5.2.3 server.

But, when I access a LAMP server (PHP 4.3.11) from GoDaddy, I get

--------------
XML error: syntax error at line 1 column 14
--------------

What am I doing wrong?

Thanks!
Les

Are you sure that the simple xml extension is enabled and that short tags are disabled

Thanks Auzzie!

I have to admit that mere words cannot communicate just how far your comments went over my head ;-}

I used phpinfo() and determined that, indeed, the server where the code worked had short_open_tag OFF, and the server where it failed had it ON.

I tried ...
-----------
ini_set("short_open_tag", 0);
$new_value=ini_get("short_open_tag");
-----------
...and found the setting didn't work (it was still = 1).

I didn't knowingly exploit the Simple XML Extension.

Can you nudge me towards portable code?

Thanks!
Les

Well i'm guessing that the host has restricted you using ini_set and as for the portable code i unfortunatly will not be able to help you with that as i try to stay away from Simple XML, maybe you could echo the start of the xml declaration?

<input type=hidden name=xdoc value='<?php echo("xml version=\"1.0\" encoding=\"UTF-8\" ?>"); ?>

then carry on as normal afterwards, or if you need to echo the entire xml

Thanks!

Your reply set off the proverbial light bulb above my head...

I stripped off the XML tag from the POST data, and changed the processing to:

****************

xml_parse($xml_parser,"<XML version=\"1.0\" encoding=\"UTF-8\">", FALSE);
xml_parse($xml_parser, $_POST, TRUE);

****************

Now all is well.

Thanks Again,
Les

This question has already been answered. Start a new discussion instead.