Reply to Re: How to parse Xml?

Your name:

Reply:


Posted by Benjamin on 08/06/07 16:06

On Aug 6, 9:44 am, php.developer2...@gmail.com wrote:
> Hi i want to parse a xml document which contains attribute can anybody
> help me in that.
>
> Example
> --------------------
> <category id="1" parent-id="1" level="2">
> <category id="2" parent-id="1" level="3">
> <category id="3" parent-id="5" level="6">
>
> I want to get all id's in this example with using regular
> expressions..
>
> Output
> ----------
> 1
> 2
> 3

First of all that's not valid XML. In order to parse it, it has to be
valid. This, however, is easily fixed in your case. Just put the whole
body in <categories> tags and add the XML declaration like this:
<?xml version="1.0"?>
<categories>
<category id="1" parent-id="1" level="2">
<category id="2" parent-id="1" level="3">
<category id="3" parent-id="5" level="6">
</categories>

With PHP, you have many options to parse XML with. My favorite and
probably the most easy is SimpleXML. Look at http://www.php.net/simplexml.

[Back to original 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

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