Re: parsing xml the right way
| From: | Justin Patrin | Date: | Fri, 02 Apr 2004 18:02:53 +0000 |
| Subject: | Re: parsing xml the right way | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-182157@lists.php.net to get a copy of this message | ||
Merlin wrote:
Hi there,
I think I am parsing xml documents the wrong way.
There must be a better way to access the results laterone like objects.
For example I would like to search in a free form for a city name
inside an xml document and php should return the country name
and continent.
This is the xml structure:
<Country size="4">
<countryName>Andorra</countryName>
<countryCode>AD</countryCode>
<countryContinent>Europe</countryContinent>
<Cities size="4">
<city>Encamp</city>
<city>Escaldes-Engordany</city>
<city>Ordino</city>
<city>Soldeu</city>
</Cities>
</Country>
Has anybody a good hint for me?
Thanx in advance,
Merlin
I created this class a short while ago that parses all of your XML into an easily usable Associative array structure. It extends PEAR::XML_Parse, so you need that as well.
http://reversefold.com/~papercrane/XML_Parser_Assoc/Assoc.phps
http://pear.php.net/package/XML_Parser
--
paperCrane <Justin Patrin>