xml parsing error when data returning from curl_exec()
Posted: Fri Mar 13, 2009 1:34 am
Hi All,
I have two files , send.php and recv.php.
I am using curl to execute the recv.php from send.php and recv.php sends back xml data to send.php. But when I display the output in send.php , it gives me error
XML Parsing Error: XML or text declaration not at start of entity
Location: http://localhost/quick/send.php
Line Number 3, Column 1:<?xml version="1.0" encoding="utf-8" ?>
^
I feel it is adding some extra characters when the xml data as string is coming from recv.php. How do i resolve this ?
Please help !
I have two files , send.php and recv.php.
I am using curl to execute the recv.php from send.php and recv.php sends back xml data to send.php. But when I display the output in send.php , it gives me error
XML Parsing Error: XML or text declaration not at start of entity
Location: http://localhost/quick/send.php
Line Number 3, Column 1:<?xml version="1.0" encoding="utf-8" ?>
^
I feel it is adding some extra characters when the xml data as string is coming from recv.php. How do i resolve this ?
Please help !
Code: Select all
//send.php
<?php
$url = 'http://localhost/quick/recv.php';
$xmlfile = implode('', file('test.xml'));
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POSTFIELDS,$xmlfile);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
header("Content-Type: application/xml");
print "$result";
curl_close($ch);
?>
//recv.php
<?php
$data = file_get_contents('php://input');
$dat = '<?xml version="1.0" encoding="utf-8" ?>
<FRMPing>
<Test>0</Test>
<Zip>92126</Zip>
<GMI>2000</GMI>
</FRMPing>';
echo "$dat";
?>