Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Read XML with PHP

    I want to be able to read something like the following with PHP:

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

    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

    Thanks

    Matt

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    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 10:37 PM.

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    That's what i'm looking for, cheers!

    Matt


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •