Hi, sorry I've asked similar questions, but still having trouble. I'm
using asp.net (vb.net). I select a node from an xmlDoc string (I've made
sure that the intended item exists), then want to determine if that node
exists, then get a certain attribute value and assign that to a
variable. Simple. But when I run it (including debug with breaks) no
value gets assigned...it just skips from my If... line to the code after
the End If.
Similar code works if I'm looking at previous-sibling, but no
following-sibling so I was hoping someone could at least tell me that my
xpath looks ok.
And any suggestion on how to debug this properly would be great!
Thanks.
Kathy
My code:
Dim xDoc As New XmlDocument()
xDoc.LoadXml(xmlString) 'that appears correctly
Dim xElem As XmlElement =
xDoc.SelectSingleNode("//Station[@name='Station1']/following-sibling::St
ation[position()=1]")
If xElem Is Nothing Then
Dim strNext As String = "End of Assembly"
Else
Dim strNext As String = xElem.Attributes.GetNamedItem("name").Value
End If
***Again, it just appears to skip from If xElem...to past End If?
Here the xmlDoc contents:
<Station name='Label'> 'this is where code runs for test
<other elements here.../>
</Station>
<Station name='Station1'> 'this is what I'm trying to get
<other elements here.../>
</Station>
...other stations etc.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!