Haveing trouble aquiring an xml document

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • google@charliefortune.com

    #1

    Haveing trouble aquiring an xml document

    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.

    <?php
    $parser=xml_par ser_create();
    xml_set_element _handler($parse r,"start_handle r","end_handler ");
    xml_set_charact er_data_handler ($parser,"chara cter_handler");
    xml_parser_set_ option($parser, XML_OPTION_CASE _FOLDING, 0);

    $soap=fopen("ht tp://webservices.ama zon.co.uk/onca/xml?Service=AWS ECommerceServic e&SubscriptionI d=0PHDGJJ5S75MM 3PERG02&Operati on=ItemSearch&S earchIndex=Book s&Keywords=live rpool&ResponseG roup=Medium","r ");

    xml_parse ($parser,$soap) or die (format_error($ parser));
    xml_parser_free ($parser);
    .....
    ....?>

    returns an XML ERROR (2) Syntax error.

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

    Thank you

  • Steve

    #2
    Re: Haveing trouble aquiring an xml document

    [color=blue]
    > $soap=fopen("ht tp://webservices.ama zon.co.uk/onca/xml?Service=AWS ECommerceServic e&SubscriptionI d=0PHDGJJ5S75MM 3PERG02&Operati on=ItemSearch&S earchIndex=Book s&Keywords=live rpool&ResponseG roup=Medium","r ");
    > xml_parse ($parser,$soap) or die (format_error($ parser));[/color]

    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,102 4);
    xml_parse($pars er,$xmldata) or die( ... );
    }
    fclose($soap);
    xml_parser_free ($parser);

    ---
    Steve

    Comment

    • google@charliefortune.com

      #3
      Re: Haveing trouble aquiring an xml document

      Of course. Thank you v much

      Comment

      Working...