Frank

Frank

  • NA
  • 1
  • 0

Need help with XPath.

Feb 23 2007 6:18 PM
Hello,

I am having some problems with XPath. First off, I would really love to read some good documentation on it. I feel that the vb.net documentation on XPath is just terrible. If you know of any really good documentation for XPath with vb.net, please point me to it. Now on to my real problem.
I have xml like this
<foo>
 <bar>blah</bar>
 <bar123>test</bar123>
</foo>

and here is that I am using (gleaned from some site mostly). This is what it looks like after tearing my hair out and trying to fix it.

Dim xpathDoc As XPathDocument
Dim xmlNav As XPathNavigator
Dim xmlNI As XPathNodeIterator

xpathDoc = New XPathDocument(path)
xmlNav = xpathDoc.CreateNavigator()
xmlNI = xmlNav.Select("/foo")
xmlNI.Current.MoveToFirst()

While (xmlNI.MoveNext())
 MsgBox(xmlNI.Current.Value)
 lstFactions.Items.Add(xmlNI.Current.Value)
 MsgBox(xmlNI.Current.Name & " : " & xmlNI.Current.Value)
End While

Anyways the output ends up being foo : blahtest

To my understanding, blahtest should be two different pieces, blah and test. I am sure that the fix is rather easy, but I am taking a .net class (sr level elective at the uni) and am coming from vb6, so things are a bit frustrating/bass ackwards/confusing/etc.

thanks for any help

-Frank