Re[2]: 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 Jochem,

Thanks for your reply. Here is a short sample of the XML I have to parse. I need
the data in the attributes as well as the data in the character fields.

<?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>




JM> me, I'm pretty convinced simpleXML is what he wants.

JM> simpleXML was a dog to use in earlier versions of php5 because simpleXML objects
JM> were 'immune' to inspection by var_dump(), print_r(), etc [meaning you be told some
JM> property was an array and then get an error if you access said property as an array,
JM> stuff like that].

JM> those problems have been helped the way of the dodo so now simpleXML really does
JM> what it says on the tin.

JM> of course there is always the options of using regular expressions or simple
JM> string manipulation functions to extract the relevant data from the string of
JM> 'xml' - technically there is no need to go anywhere near a 'real' xml parser
JM> as such.

So far I have had no luck with simpleXML at all.

Regards

Richard Luckhurst

-- 
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