XML Query

swingard

Member
Joined
Dec 21, 2006
Messages
6
Programming Experience
1-3
I need to query an XML document with the following structure:

HTML:
<Laubbäume>
<LBAUM>
<ID>414</ID>
<Kronendurchmesser>10</Kronendurchmesser>
</LBAUM>
</Laubbäume>

I want to do something like in SQL:

VB.NET:
SELECT Kronendurchmesser WHERE ID=414

Thanks!!
 
Last edited by a moderator:
XPath is the Xml query language. Example:
VB.NET:
Dim xdoc As New Xml.XmlDocument
xdoc.Load("laub.xml")
Dim xnode As Xml.XmlNode = xdoc.SelectSingleNode("/Laubbäume/LBAUM[ID='414']/Kronendurchmesser")
The select statement is selecting the Kronendurchmesser node of a LBAUM node whose ID child node is value '414'). Xnode variable is here Nothing if expression don't resolve to a node.
 
Back
Top