| | |
Stupid Newbie Needs Help w/xml_parse
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Solved Threads: 0
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['xdoc'];
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
--------------
<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['xdoc'];
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
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Nov 2007
Posts: 121
Reputation:
Solved Threads: 16
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?
then carry on as normal afterwards, or if you need to echo the entire xml
PHP Syntax (Toggle Plain Text)
<input type=hidden name=xdoc value='<?php echo("xml version=\"1.0\" encoding=\"UTF-8\" ?>"); ?>
Last edited by Auzzie; Mar 12th, 2008 at 9:20 pm.
•
•
Join Date: Mar 2008
Posts: 3
Reputation:
Solved Threads: 0
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['xdoc'], TRUE);
****************
Now all is well.
Thanks Again,
Les
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['xdoc'], TRUE);
****************
Now all is well.
Thanks Again,
Les
![]() |
Other Threads in the PHP Forum
- Previous Thread: Popups
- Next Thread: Multiple search
| Thread Tools | Search this Thread |
apache api array beginner binary broken cache cakephp checkbox class cms code confirm cron curl customizableitems database date display dynamic echo email error external fcc file files folder form forms forum freelancing function functions google header headmethod howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction menu method mlm mod_rewrite multiple mysql neutrality oop pageing pagerank paypal pdf php phpmysql play problem query question radio random recursion remote root script search select server sessions sms soap source space sql support! syntax system table template tutorial update upload url validator variable video web youtube





