xml xquery and php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Manish

    #1

    xml xquery and php

    I am new to XML. Initially I was saving all the settings in either PHP
    or text files or database tables and use to parse the config variables
    from files or query from the database. Now I want to keep all the
    settings in the XML file and get the setting values, user datas (as
    database is not involved and all the results are stored in XML file
    itself) from it.

    Referring to http://www.w3schools.com/xquery/xquery_example.asp, it
    gives sample xml file and also query. But I don't know how to execute
    it.
    -------------------------------------------------------------------------------------------------------------

    "books.xml" :

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <bookstore>

    <book category="COOKI NG">
    <title lang="en">Every day Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
    </book>

    <book category="CHILD REN">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
    </book>

    <book category="WEB">
    <title lang="en">XQuer y Kick Start</title>
    <author>James McGovern</author>
    <author>Per Bothner</author>
    <author>Kurt Cagle</author>
    <author>James Linn</author>
    <author>Vaidyan athan Nagarajan</author>
    <year>2003</year>
    <price>49.99</price>
    </book>

    <book category="WEB">
    <title lang="en">Learn ing XML</title>
    <author>Erik T. Ray</author>
    <year>2003</year>
    <price>39.95</price>
    </book>

    </bookstore>

    -------------------------------------------------------------------------------------------------------------

    doc("books.xml" )/bookstore/book[price<30]

    The XQuery above will extract the following:

    <book category="CHILD REN">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
    </book>

    -------------------------------------------------------------------------------------------------------------

    I have a PHP 5 installed on the computer. I want to know, provided the
    XML file, how do I execute the query and get the results. Are there
    some API, Packages avaailable.

    Please also suggest XML user groups.

    Thanks.

    Manish

Working...