EDN Admin
Well-known member
Is there a better way to create the following query?? Im not happy with the use of parent to travel back up the node path but cant figure out how to write the query at the correct level without it.
Any ideas?
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim xd <span style="color:Blue; As XDocument = _
<?xml version=<span style="color:#A31515; "1.0" encoding=<span style="color:#A31515; "utf-8"?>
<root>
<element>
<subelement id=<span style="color:#A31515; "1">
<subsubelement id=<span style="color:#A31515; "1"/>
<subsubelement id=<span style="color:#A31515; "3"/>
<subsubelement id=<span style="color:#A31515; "1"/>
</subelement>
<subelement id=<span style="color:#A31515; "2"/>
<subelement id=<span style="color:#A31515; "3"/>
</element>
<element>
<subelement id=<span style="color:#A31515; "4"/>
<subelement id=<span style="color:#A31515; "1"/>
<subelement id=<span style="color:#A31515; "2">
<subsubelement id=<span style="color:#A31515; "1"/>
<subsubelement id=<span style="color:#A31515; "1"/>
<subsubelement id=<span style="color:#A31515; "3"/>
</subelement>
<subelement id=<span style="color:#A31515; "5"/>
</element>
</root>
<span style="color:Blue; Dim results = <span style="color:Blue; From q <span style="color:Blue; In xd.Descendants.<element>
results = <span style="color:Blue; From q <span style="color:Blue; In results.<subelement> <span style="color:Blue; Where q.@id = 1 <span style="color:Blue; Select q.Parent
results = <span style="color:Blue; From q <span style="color:Blue; In results.<subelement>.<subsubelement> <span style="color:Blue; Where q.@id = 3 <span style="color:Blue; Select q.Parent.Parent
[/code]
View the full article
Any ideas?
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim xd <span style="color:Blue; As XDocument = _
<?xml version=<span style="color:#A31515; "1.0" encoding=<span style="color:#A31515; "utf-8"?>
<root>
<element>
<subelement id=<span style="color:#A31515; "1">
<subsubelement id=<span style="color:#A31515; "1"/>
<subsubelement id=<span style="color:#A31515; "3"/>
<subsubelement id=<span style="color:#A31515; "1"/>
</subelement>
<subelement id=<span style="color:#A31515; "2"/>
<subelement id=<span style="color:#A31515; "3"/>
</element>
<element>
<subelement id=<span style="color:#A31515; "4"/>
<subelement id=<span style="color:#A31515; "1"/>
<subelement id=<span style="color:#A31515; "2">
<subsubelement id=<span style="color:#A31515; "1"/>
<subsubelement id=<span style="color:#A31515; "1"/>
<subsubelement id=<span style="color:#A31515; "3"/>
</subelement>
<subelement id=<span style="color:#A31515; "5"/>
</element>
</root>
<span style="color:Blue; Dim results = <span style="color:Blue; From q <span style="color:Blue; In xd.Descendants.<element>
results = <span style="color:Blue; From q <span style="color:Blue; In results.<subelement> <span style="color:Blue; Where q.@id = 1 <span style="color:Blue; Select q.Parent
results = <span style="color:Blue; From q <span style="color:Blue; In results.<subelement>.<subsubelement> <span style="color:Blue; Where q.@id = 3 <span style="color:Blue; Select q.Parent.Parent
[/code]
View the full article