You are here: Re: xml has multiple tags with same name for different values problem « All PHP « IT news, forums, messages
Re: xml has multiple tags with same name for different values problem

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация