Haveing trouble aquiring an xml document

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am making a soap request to an amazon server and trying to parse the
xml. The request -


is succesful in my browser. But I can't get it into my script.

    xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING, 0);

$soap=fopen("http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&SubscriptionId=0PHDGJJ5S75MM3PERG02&Operation=ItemSearch&SearchIndex=Books&Keywords=liverpool&ResponseGroup=Medium ","r");

    xml_parse ($parser,$soap) or die (format_error($parser));

returns an XML ERROR (2) Syntax error.

Is it that fopen is not the correct way to aquire the xml ?

Thank you

Re: Haveing trouble aquiring an xml document

Quoted text here. Click to load it

Don't pass the file handle to xml_parse(). Get some data from the file
handle and pass that. You can either get /all/ the data and pass it in
one lump, or make multiple calls to fread() and pass each chunk until
there's no more to read.

while( !feof($soap) )
   $xmldata = fread($soap,1024);
   xml_parse($parser,$xmldata) or die( ... );


Re: Haveing trouble aquiring an xml document

Of course. Thank you v much

Site Timeline