I'm stuck with an XPath query to produce a TreeView.
From the data below, I want to select all the score elements having an IdIn
of 2018, ***including their ancestors***.
With the result, I want to fill a TreeView control.
This is my simplified data:
<?xml version="1.0" encoding="utf-8"?>
<Punten>
<test Titel="TRAINING " >
<test Titel="web" >
<test Titel="Excel" >
<test Titel="Eindtest Excel" >
<score IdIn="1878" Score="12" />
<score IdIn="2011" Score="14" />
<score IdIn="2018" Score="15" />
</test>
</test>
<test Titel="VB" >
<test Titel="TEST1" >
<score IdIn="2127" Score="20" />
<score IdIn="2018" Score="17" />
<score IdIn="2037" Score="11" />
</test>
</test>
<test Titel="ASP" >
<test Titel="Examen" >
<score IdIn="1878" Score="28" />
<score IdIn="2011" Score="-998" />
<score IdIn="2018" Score="60" />
</test>
</test>
</test>
<test Titel="web2" >
<test Titel="Excel" >
<test Titel="Eindtest Excel" >
<score IdIn="2042" Score="13" />
<score IdIn="2091" Score="12" />
<score IdIn="1818" Score="13" />
</test>
</test>
<test Titel="Flash" Soort="Vak" >
<test Titel="flintsto nes" >
<score IdIn="2091" Score="6" />
<score IdIn="2087" Score="10" />
<score IdIn="2123" Score="5" />
</test>
</test>
</test>
</test>
</Punten>
This is the tree I want to produce (the scores with IdIn=2018):
<Punten>
<test Titel="TRAINING " >
<test Titel="web" >
<test Titel="Excel" >
<test Titel="Eindtest Excel" >
<score IdIn="2018" Score="15" />
</test>
</test>
<test Titel="VB" >
<test Titel="TEST1" >
<score IdIn="2018" Score="17" />
</test>
</test>
<test Titel="ASP" >
<test Titel="Examen" >
<score IdIn="2018" Score="60" />
</test>
</test>
</test>
</test>
</Punten>
I have tried this XPath value (with an XmlDataSource):
//score[@IdIn='3234']/ancestor-or-self::*
It should give me what I want, but it produces an error in
TreeView.DataBi ndRecursive:
Object reference not set to an instance of an object
The query
//test[not(@Verwijderd ='1')]/score[@IdIn='3234']
works without an error, but only produces the "scores" items
Does anybody know a working XPath query for this?
Any help with this problem is appreciated.
--
Riki
From the data below, I want to select all the score elements having an IdIn
of 2018, ***including their ancestors***.
With the result, I want to fill a TreeView control.
This is my simplified data:
<?xml version="1.0" encoding="utf-8"?>
<Punten>
<test Titel="TRAINING " >
<test Titel="web" >
<test Titel="Excel" >
<test Titel="Eindtest Excel" >
<score IdIn="1878" Score="12" />
<score IdIn="2011" Score="14" />
<score IdIn="2018" Score="15" />
</test>
</test>
<test Titel="VB" >
<test Titel="TEST1" >
<score IdIn="2127" Score="20" />
<score IdIn="2018" Score="17" />
<score IdIn="2037" Score="11" />
</test>
</test>
<test Titel="ASP" >
<test Titel="Examen" >
<score IdIn="1878" Score="28" />
<score IdIn="2011" Score="-998" />
<score IdIn="2018" Score="60" />
</test>
</test>
</test>
<test Titel="web2" >
<test Titel="Excel" >
<test Titel="Eindtest Excel" >
<score IdIn="2042" Score="13" />
<score IdIn="2091" Score="12" />
<score IdIn="1818" Score="13" />
</test>
</test>
<test Titel="Flash" Soort="Vak" >
<test Titel="flintsto nes" >
<score IdIn="2091" Score="6" />
<score IdIn="2087" Score="10" />
<score IdIn="2123" Score="5" />
</test>
</test>
</test>
</test>
</Punten>
This is the tree I want to produce (the scores with IdIn=2018):
<Punten>
<test Titel="TRAINING " >
<test Titel="web" >
<test Titel="Excel" >
<test Titel="Eindtest Excel" >
<score IdIn="2018" Score="15" />
</test>
</test>
<test Titel="VB" >
<test Titel="TEST1" >
<score IdIn="2018" Score="17" />
</test>
</test>
<test Titel="ASP" >
<test Titel="Examen" >
<score IdIn="2018" Score="60" />
</test>
</test>
</test>
</test>
</Punten>
I have tried this XPath value (with an XmlDataSource):
//score[@IdIn='3234']/ancestor-or-self::*
It should give me what I want, but it produces an error in
TreeView.DataBi ndRecursive:
Object reference not set to an instance of an object
The query
//test[not(@Verwijderd ='1')]/score[@IdIn='3234']
works without an error, but only produces the "scores" items
Does anybody know a working XPath query for this?
Any help with this problem is appreciated.
--
Riki
Comment