Re: Parsing an XML return from a POST - resend with a little more information

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



    Hi,
    From all XML parsers I tried I loved the most:

www.phpclasses.org/browse/package/1328.html

    The advantage is that you don't need any extra addons to php or
anything else. It's pure php.

    Andrei

Richard Luckhurst wrote:
> Hi List
>
> I am sending this to the list again with a bit more information in the hope I
> can get some help.
>
> There is a requirement to send a request to a server and I now have that working
> using cURL, thanks to help from this list. I now have the responses coming back
> as an XML response. What I need to do is to parse the XML response and break it
> up into either an array or variables so I can pass the returned responses back
> to a calling process.
>
> I have spent most of last night and today looking at XML parsing and now am
> totally confused. Some testing I have done suggests that SimpleXML is not the
> way to go however I am open to suggestions if it might be an answer.
>
> I have spent ages searching Google and looking at XML parser examples. Now I am
> more confused than ever.
>
> I would appreciate any help or advice on how to parse this XML response and break it up
> into either an array or individual variables. It is important for this
> application to not only get the data contained between beginning and end tags
> but also the attributes as they contain important data returned from the server.
> I am the first to admit that PHP XML Parsing has me lost.
>
> One other question I do have is that all of the examples I have seen, using the
> xml_parser, seem to be designed around a file being read into the parser. Is it
> possible for the XML data to be contained in a variable and then used in the
> parser?
>
> I have included a sample response from the server below. A few points to be
> aware of,
>
> 1) In the fares section there could be any number of fares however each fare
> will have a fareID and then the fareBases child.
> 2) In the tarifs section there could be any number of tarifs however each tarif
> will have a tarifId and then 1 or more fareXrefs.
> 3) In the vcrSummary section there could be 1 or more vcr entries
> 4) The response comes back as one long string and I have formatted this to make
> it a little easier to read.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?ypsilon RNGSchema="fareResponse.rnc" type="compact"?>
> <fareResponse cntTarifs="122" offset="0">
>   <fares>
>         <fare fareId="11429927" fareType="PUB" checked="false" class="V" depApt="SYD" dstApt="LON" paxType="ADT" vcr="OS" cos="E" yyFare="false" avail="false">
>                 <fareBases>
>                         <fareBase pax="ADT">VLOX2</fareBase>
>                         <fareBase pax="CHD">VLOX2</fareBase>
>                         <fareBase pax="INF">VLOX2</fareBase>
>                 </fareBases>
>         </fare>
>         <fare fareId="11429924" fareType="PUB" checked="false" class="M" depApt="SYD" dstApt="LON" paxType="ADT" vcr="OS" cos="E" yyFare="false" avail="false">
>                 <fareBases>
>                         <fareBase pax="ADT">MLOW2</fareBase>
>                         <fareBase pax="CHD">MLOW2</fareBase>
>                         <fareBase pax="INF">MLOW2</fareBase>
>                 </fareBases>
>         </fare>
>   </fares>
>   <tarifs currency="USD">
>         <tarif tarifId="11429927" adtBuy="675.07" adtSell="675.07" chdBuy="675.07" chdSell="675.07" infBuy="675.07" infSell="675.07" topCar="false" topHotel="false">
>                 <fareXRefs>
>                         <fareXRef>11429927</fareXRef>
>                 </fareXRefs>
>         </tarif>
>         <tarif tarifId="11429926" adtBuy="714.83" adtSell="714.83" chdBuy="714.83" chdSell="714.83" infBuy="714.83" infSell="714.83" topCar="false" topHotel="false">
>                 <fareXRefs>
>                         <fareXRef>11429926</fareXRef>
>                 </fareXRefs>
>         </tarif>
>   </tarifs>
>   <taxes currency="USD">
>         <tax vcr="OS">201.52</tax>
>   </taxes>
>   <vcrSummary>
>         <vcr minPrice="1667" maxPrice="1667" totalTarifs="1" currency="USD">AA</vcr>
>         <vcr minPrice="1374" maxPrice="4704" totalTarifs="2" currency="USD">PR</vcr>
>   </vcrSummary>
> </fareResponse>
>
>   
> I would certainly appreciate any help I can get. Thanks in advance.
>
>
>
> Regards,
> Richard Luckhurst                      
> Product Development
> Exodus Systems - Sydney, Australia.
> rluckhurst@xxxxxxxxxxxxx
>
>   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux