Forum Moderators: coopster

Message Too Old, No Replies

XML parser in PHP

confused about tags and any simple method

         

TechMan

8:27 am on Sep 23, 2008 (gmt 0)

10+ Year Member



Hi,

I want to read an XML file which can be reached here.

<snip>

I looked for XML parsers on Google and found several results which were using PHP Expat to do the job. But I found out that to parse any XML file you must know its structure and tags. That is each parser will be tailor made to read that particular XML file. Now my questions are:

1. Is there a generic parser available that will read all nodes and data?

2. Looking at the XML file above which I want to read can you suggest one or two nodes which I can used in PHP? I am a little confused because all the examples are using simple XML files with tags like <author> and <title> e.t.c but my XML file has tags like following:

<tr class="row_heading">
<tr class="row_odd">
<td align="left">

So tell me shall I use tag <tr> or <tr class="row_heading">

[edited by: dreamcatcher at 9:27 am (utc) on Sep. 23, 2008]
[edit reason] No urls please! [/edit]

Sekka

11:24 am on Sep 23, 2008 (gmt 0)

10+ Year Member



PHP has built in XML modules that parse the document to make sure it has a valid structure.

To parse a document for valid data however, you will need to construct your own validator, there is no round this. This is because the data you want is specific to your needs.

Try looking at the XMLReader class,

[uk2.php.net...]