I had a question about using xpath queries to find specific data in an xml
Xml Document.
Say I had this for an xml document
<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<firstname>Benjamin</firstname>
<lastname>Franklin</lastname>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<firstname>Herman</firstname>
<lastname>Melville</lastname>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<firstname>Plato</firstname>
<lastname></lastname>
</author>
<price>9.99</price>
</book>
</bookstore>
And I want to retreive the data that is in the firstname and
lastname nodes.
Now if I have a code like this:
Dim first As String
Dim last As String
Dim Doc As XPathDocument = New XPathDocument("books.xml")
Dim Navigator As XPathNavigator
Navigator = Doc.CreateNavigator()
Dim Iterator As XPathNodeIterator = Navigator.Select("/bookstore/book/author")
While Iterator.MoveNext()
If something happens here
End While
How do I say if the node name is equal to firstname then first
equal to the value in firstname.
I am using vb.net 2005 by the way.
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).