Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Querying XML

Reply
Thread Tools

Querying XML

 
 
warrenbbs@googlemail.com
Guest
Posts: n/a
 
      06-19-2007
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-19-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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/
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      06-19-2007
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
 
Reply With Quote
 
warrenbbs@googlemail.com
Guest
Posts: n/a
 
      06-19-2007
Thanks guys - didn't realise it was quite so straightforward!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How would you do this: sorting/querying an XML file... darrel ASP .Net 2 03-21-2007 02:03 PM
Querying for a set sequence against an XML Document manojas@hotmail.com XML 0 08-01-2006 10:53 PM
Querying XML Files =?Utf-8?B?QmFobWFu?= ASP .Net 12 10-08-2005 04:45 PM
Querying huge Xml Documents in a user friendly way Hakan Akkas XML 1 11-16-2004 07:08 PM
Help with Querying XML Document VJ XML 4 11-07-2003 06:02 AM



Advertisments