View Full Version : Read XML with PHP

02-05-2003, 08:24 PM
I want to be able to read something like the following with PHP:

<tag id="x">Info</tag>
<open name="x" num="y">Info</open>

Is this possible? if so could you help!!!

The reason is cos I am running a site using txt files and I would prefer to use XML. Have a look (http://www.missingscore.co.uk)



02-05-2003, 09:34 PM
There are two ways I know of:

1 - there's a simple api for XML which is native to PHP4 - documented at http://www.php.net/manual/en/ref.xml.php - It works well and it's stable, but there's no validation and it's not a DOM parser - it has no concept of the nature of the document, it just stores the nodes, attributes and values in PHP variables. My experience was initially very positive, but I was more interested in XSLT ...

2 - PHP has XSLT function - documented at http://www.php.net/manual/en/ref.xslt.php - for this you need to install an extension called Sablotron - http://www.gingerall.com/charlie/ga/xml/x_sabphp.xml - and it truly rocks :) Really simple - takes about 4 lines of PHP, which is particularly great if you want environment independence for your data - and it's a true DOM parser with full XPath support. This is my recomendation :thumbsup:

02-06-2003, 05:22 AM
That's what i'm looking for, cheers!


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum