Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > XPath Query

Reply
Thread Tools

XPath Query

 
 
Michael C#
Guest
Posts: n/a
 
      01-18-2005
OK, here's the deal. I have a small XML file that represents a small
database table. I load it into a System.XML.XMLDocument. So far so good.
I run an XPath query against it to retrieve all the field names. Everything
there works fine.

Here's my XML Document:

<?xml version="1.0" standalone="yes" ?>
<DataSet1 xmlns="http://www.tempuri.org/DataSet1.xsd">
<tblItem>
<ID>1</ID>
<Name>Spam</Name>
<Category>Food</Category>
<Description>Yummy! No natural ingredients</Description>
<Price>4</Price>
<ImageURL>images/1.png</ImageURL>
<LargeImageURL>images/L1.png</LargeImageURL>
</tblItem>
<tblItem>
<ID>2</ID>
<Name>Remote Control</Name>
<Category>Miscellaneous</Category>
<Description>Universal Remote</Description>
<Price>12</Price>
<ImageURL>images/2.png</ImageURL>
<LargeImageURL>images/L2.png</LargeImageURL>
</tblItem>
</DataSet>

Now for the tricky part. I'm trying to come up with three XPath queries
that will return the following:

1) All tblItem nodes that have a child ID node with a value of 1 (i.e., all
tblItem where ID = 1),
2) All tblItem nodes that have a Category of Miscellaneous (i.e., all
tblItem where Category = 'Miscellaneous')
3) All tblItem ndoes that have the word Remote in the Description (i.e., all
tblItem where Category contains the word 'Remote' in any position)

Coming from a SQL background, I'm having a hard time implementing XPath
expressions. I was hoping someone here could point me in the right
direction. I've tried several combinations, like "tblItem/ID[.='1']",
"tblItem[ID='1']" and "//tblItem[ID='Miscellaneous']". None of them seem to
be working though...

TIA


 
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
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
xpath query query David Gordon XML 2 05-18-2005 03:33 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments