Hi List
I am working owards completing a rather urgent project for one of our clients.
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 would
appreciate any help or advice on how to parse this XML response and break it up
into either an array or individual variables.
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.
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php