I am writing program that reads in some XML from the $_POST variable and then parses using the PHP XMLReader and the data extracted input into a database. I am using the XMLReader as the XML supplied will more than likely be too big to place into memory.
However I am having some issues, my XML and basic code as are follows:
'<?xml version="1.0"?>
<data_root>
<data>
<info>value</info>
</data>
<action>value</action>
</data_root>'
$request = $_REQUEST['xml'];
$reader = new XMLReader();
$reader->XML($request);
while($reader->read()){
//processing code
}
$reader->close()
My problem is that the code will work perfectly if the XML being passed does not have the <?xml version="1.0"?>
line, but if i include it, and it will be included when the application goes into a live production environment, the $reader->read()
code for the while loop does not work and the XML is not parsed within the while loop.
Has anyone seen similar behaviour before or knows why this could be happening?
Thanks in advance.
ok, major redfaced coder here, having made some changes to my dev environment, i installed a new version of php yesterday, and magic_quotes_gpc was set to 'on' thus escaping the quotes in the XML and causing the problem
thank you for your assistance