XmlDocument.SelectNodes

G

Guest

Hello,

I am using .NET XmlDocument object to load the xml file.
Please look at the below given sample xml file for the refence.
using objXmlDoc.SelectNodes("//bookstore/book/first-name="Jane" and
last-name="Austen") where it should return me the list of (<book...>)Nodes
which has child node first-name="Jane" and last-name="Austen".

Basically I have to fetch list of books based on first AND last name of the
book author.

Thanks in advance

With Regards
Venkat

* This question is posted in xsl group also.

<?xml version="1.0"?>
<bookstore xmlns:bk="urn:samples">
<book genre="novel" publicationdate="1997" bk:ISBN="1-861001-57-8">
<title>Pride And Prejudice</title>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
<price>24.95</price>
</book>
<book genre="novel" publicationdate="1992" bk:ISBN="1-861002-30-1">
<title>The Handmaid's Tale</title>
<first-name>Margaret</first-name>
<last-name>Atwood</last-name>
<price>29.95</price>
</book>
<book genre="novel" publicationdate="1991" bk:ISBN="1-861001-57-6">
<title>Emma</title>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
<price>19.95</price>
</book>
<book genre="novel" publicationdate="1982" bk:ISBN="1-861001-45-3">
<title>Sense and Sensibility</title>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
<price>19.95</price>
</book>
</bookstore>
 
J

Jon Skeet [C# MVP]

Venkatachalam said:
I am using .NET XmlDocument object to load the xml file.
Please look at the below given sample xml file for the refence.
using objXmlDoc.SelectNodes("//bookstore/book/first-name="Jane" and
last-name="Austen") where it should return me the list of (<book...>)Nodes
which has child node first-name="Jane" and last-name="Austen".

Try "//bookstore/book[first-name='Jane' and last-name='Austen']

See http://www.w3schools.com/xpath/ for an XPath tutorial.

Jon
 

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

Top