Querying XML

Discussion in 'XML' started by warrenbbs@googlemail.com, Jun 19, 2007.

  1. Guest

    Hi

    I'm completely new to the XML world (yes, welcome to the 21st
    century!) and am working on a project where I will be supplied a daily
    xml document that needs to be queried.

    The scenario is that I'm working for a recruitment company and they
    want a simple website interface where users can browse their vacancies
    by clicking through several options - e.g. Click on their choice of
    location, then click on salary range, then job type. So I need the
    "search results" page to show the relevant vacancies according to what
    they've clicked.

    I'm able to do this easily enough in php/mySQL, but not sure how to
    work with XML. I've read up a bit on XPath, but not seen any examples
    of how to show the results of *multiple* search criteria, like in SQL:
    SELECT * FROM table WHERE salary=X AND location=Y AND job_type=Z

    Are there any useful tutorials on this kind of thing, or is anyone out
    there able to shed some light? I'll be working in a PHP5 environment.

    Thanks
    Warren
     
    , Jun 19, 2007
    #1
    1. Advertising

  2. wrote:

    > I'm able to do this easily enough in php/mySQL, but not sure how to
    > work with XML. I've read up a bit on XPath, but not seen any examples
    > of how to show the results of *multiple* search criteria, like in SQL:
    > SELECT * FROM table WHERE salary=X AND location=Y AND job_type=Z
    >
    > Are there any useful tutorials on this kind of thing, or is anyone out
    > there able to shed some light? I'll be working in a PHP5 environment.


    Assuming you have XML like this
    <table>
    <row>
    <salary>1234</salary>
    <location>London</location>
    <job_type>webmaster</job_type>
    </row>
    <row>
    <salary>1000</salary>
    <location>Oxford</location>
    <job_type>junior webmaster</job_type>
    </row>
    <!-- further row elements here -->
    </table>
    then you can use an XPath expression alike
    /table/row[salary >= 1000 and location = 'London' and job_type =
    'webmaster']
    to select all matching row elements.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jun 19, 2007
    #2
    1. Advertising

  3. And if you need more power, the XSLT transformation language and/or the
    XQuery language provide additional looping, sorting, and formatting
    capabilities on top of XPath searches. (XSLT 2.0 and XQuery 1.0 are
    actually pretty close to semantically equivalent -- their specs are
    literally generated from the same source files to help keep them
    consistent with each other -- but they're tuned for different kinds of
    tasks.)

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Jun 19, 2007
    #3
  4. Guest

    Thanks guys - didn't realise it was quite so straightforward!
     
    , Jun 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QmFobWFu?=

    Querying XML Files

    =?Utf-8?B?QmFobWFu?=, Oct 7, 2005, in forum: ASP .Net
    Replies:
    12
    Views:
    1,264
    Ken Cox [Microsoft MVP]
    Oct 8, 2005
  2. VJ
    Replies:
    4
    Views:
    439
    Dimitre Novatchev
    Nov 7, 2003
  3. Hakan Akkas
    Replies:
    1
    Views:
    513
    Joris Gillis
    Nov 16, 2004
  4. Replies:
    0
    Views:
    346
  5. darrel
    Replies:
    2
    Views:
    304
    darrel
    Mar 21, 2007
Loading...

Share This Page