Querying XML

W

warrenbbs

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
 
M

Martin Honnen

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.
 
J

Joe Kesselman

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.)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top