G
Guest
Hey there,
I'm having trouble finding the right XPath expression. The XML file I'm
parsing contains an element Heads which contains sereveral Head elements.
These Head elements have several Row sub-elements.
Heads ->(0..*)Head -> ...subelements... -> (0..*)Row
The problem I have is that I find the wrong Row elements, ie I always find
the FIRST Row element inside the complete Xml document. This is probably
caused by a bad XPath expression I gave
Can you help me?
What I do is the following. Each Head has an index element (Index), each Row
also has an Index element. First I try to find the Head. I start searching
from the Heads node within the Xml file:
XmlNode headsNode = xmlDoc.SelectSingleNode( "//Heads" );
XmlNode baseHeadNode = headsNode.SelectSingleNode( "//Head[Index=i]" );
XmlNode rowNode = baseHeadNode.SelectSingleNode( "//Row[Index=0]" );
The i is a number between 0 and #heads-1. The last statement always gives me
the first Row with Index 0 inside the whole XML file, NOT the Row with Index
0 that is found under Head with Index i.
What is wrong with my XPath expression?
I'm having trouble finding the right XPath expression. The XML file I'm
parsing contains an element Heads which contains sereveral Head elements.
These Head elements have several Row sub-elements.
Heads ->(0..*)Head -> ...subelements... -> (0..*)Row
The problem I have is that I find the wrong Row elements, ie I always find
the FIRST Row element inside the complete Xml document. This is probably
caused by a bad XPath expression I gave

What I do is the following. Each Head has an index element (Index), each Row
also has an Index element. First I try to find the Head. I start searching
from the Heads node within the Xml file:
XmlNode headsNode = xmlDoc.SelectSingleNode( "//Heads" );
XmlNode baseHeadNode = headsNode.SelectSingleNode( "//Head[Index=i]" );
XmlNode rowNode = baseHeadNode.SelectSingleNode( "//Row[Index=0]" );
The i is a number between 0 and #heads-1. The last statement always gives me
the first Row with Index 0 inside the whole XML file, NOT the Row with Index
0 that is found under Head with Index i.
What is wrong with my XPath expression?