[RESOLVED] Odd XPath behavior
Why does the following code produce 'WILD' rather than 'BILL'?
Code:
Dim xml As String = _
"<ROOT>" & _
" <CHILD1>" & _
" <NAME>WILD</NAME>" & _
" </CHILD1>" & _
" <CHILD2>" & _
" <NAME>BILL</NAME>" & _
" </CHILD2>" & _
"</ROOT>"
Dim doc As New XmlDocument
doc.LoadXml(xml)
Dim child2 As XmlNode = doc.SelectSingleNode("//CHILD2")
Dim name As Xml.XmlNode = child2.SelectSingleNode("//NAME")
Debug.WriteLine(name.InnerText)
Re: [RESOLVED] Odd XPath behavior
I would guess that the // is forcing it to start back at the root node. Guess lookup how the xpath syntax works to get the answer.