find position node controlling xpath
anyone know position node controlling xpath?
say i have following xml:
<a>
<b>zyx</b>
<b>wvu</b>
<b>tsr</b>
<b>qpo</b>
</a>
i following xpath query name third <b> node (<b>tsr</b>):
a/b[.='tsr']
which good good nonetheless i wish return ordinal position node, something like:
a/b[.='tsr']/position()
(but bit some-more working!)
is even possible?
edit: forgot plead am controlling .net 2 it's xpath 1.0!
update: finished adult controlling 's . those prying here's doing c#:
int position = doc.selectnodes("a/b[.='tsr']/preceding-sibling::b").count + 1;
// check node indeed exists
if (position > 1 || doc.selectsinglenode("a/b[.='tsr']") != null)
{
console.writeline("found during position = {0}", position);
}
Comments
Post a Comment