I am using curl and xml to post my xml to a URL.
I am getting response from it right now, but its not displaying in output.
when I take the View Source
page by right clicking its there like the XML file output.
I need to store that xml document to a file.
I used this code below
<?
$path = "https://newport.ingrammicro.com/mustang"; //Relative path to the file with $_POST parsing
$ch = curl_init($path); //Initialise curl resource with above file
$data = "my xml document to post";
//Data to be sent to the file
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //Send the data to the file?
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_HEADER, 0);
$val = curl_exec($ch);
curl_close($ch); //Close curl session
$fp = fopen('data.xml', 'w');
fwrite($fp, $val);
fclose($fp);
?>
but when I opened the saved file only a single value "1"
this is the value I'm getting in the file.
actually its the true value from the curl statement($val = curl_exec($ch); ) bool(true) i tried to echo the value of Sval , it also "1"
How can i save my XML output file exactly as the XML file output.when i take view page source
it will look like this
<PNAResponse>
<Version>2.0</Version>
<TransactionHeader>
<SenderID>14-018111</SenderID>
<ReceiverID>14-018111</ReceiverID>
<ErrorStatus ErrorNumber=""/>
<DocumentID>{F1B17BBB-F848-4693-914A-B6943AA9009A}</DocumentID>
<TransactionID/>
<TimeStamp>2009-06-17T22:42:44</TimeStamp>
</TransactionHeader>
<PriceAndAvailability SKU="V06669" Quantity="5" GovtProgramType="PA" GovtEndUserType="F">
<Price>1413.04</Price>
<SpecialPriceFlag>Y</SpecialPriceFlag>
<ManufacturerPartNumber>V11H270020</ManufacturerPartNumber>
<ManufacturerPartNumberOccurs/>
<VendorNumber>4913</VendorNumber>
<Description>POWERLITE 1735W LCD PROJ</Description>
<ReserveInventoryFlag>N</ReserveInventoryFlag>
<AvailableRebQty>0</AvailableRebQty>
<Branch ID="10" Name="Mira Loma, California">
<Availability>7</Availability>
<OnOrder>8</OnOrder>
<ETADate>2009-06-19</ETADate>
</Branch>
<Branch ID="30" Name="Millington, Tennessee">
<Availability>0</Availability>
<OnOrder>4</OnOrder>
<ETADate>2009-06-22</ETADate>
</Branch>
<Branch ID="40" Name="Carol Stream, Illinois">
<Availability>0</Availability>
<OnOrder>18</OnOrder>
<ETADate>2009-06-18</ETADate>
</Branch>
<Branch ID="80" Name="Jonestown Pennsylvania">
<Availability>0</Availability>
<OnOrder>9</OnOrder>
<ETADate>2009-06-23</ETADate>
</Branch>
</PriceAndAvailability>
</PNAResponse>
Does anyone have an idea how to do this?