|
Posted by Oli Filth on 10/13/87 11:29
google@charliefortune.com said the following on 17/10/2005 21:01:
> I am parsing xml responses from Amazon Web Service queries. The problem
> is, the doc contains elements like
>
> <lowestnewprice>
> <formattedprice>4.99</formattedprice>
> <amount>499</amount>
> </lowestnewprice>
> <lowestusedprice>
> <formattedprice>2.99</formattedprice>
> <amount>299</amount>
> </lowestusedprice>
>
> For now, I only want the lowest used price, but my parser is looking
> for <amount>, and is returning me the first one. I considered putting
> each instance into an array, but I cannot be sure that all the xml
> trees for each product contain the same amount of elements. If a
> product is not available new, maybe the first instance would be the
> lowestusedprice, not the lowestnewprice as I normal.
>
> How can I approach this, please..?
If you used the XML Parser functions, this would be no problem at all.
See http://www.php.net/manual/ref.xml.php
In your element handler, set a flag when you receive a "lowestusedprice"
element, and then the next "amount" will be the one you want (clear the
flag when you receive a closing "lowestusedprice".
--
Oli
Navigation:
[Reply to this message]
|