Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
Thread: Read XML with PHP
02-05-2003, 08:24 PM #1
Read XML with PHP
I want to be able to read something like the following with PHP:
<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
02-05-2003, 09:34 PM #2
- Join Date
- Jun 2002
- near Oswestry
- Thanked 0 Times in 0 Posts
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
Last edited by brothercake; 02-05-2003 at 09:37 PM.
02-06-2003, 05:22 AM #3