Forum Navigation
XPath.descendant problem?
Moderators:
kris
Posted: 02/27/08 12:02:38 Modified: 02/27/08 12:03:40This might be the default XPath behaviour (I've just started looking at it), but it seems a bit odd to me Look at the last line. I would expect descendant to also include the children of the node, but it doesn't. If this is the intended behaviour, a way to concat NodeSets? would be nice.
I found this in the w3 docs:
the descendant axis contains the descendants of the context node; a descendant is a child or a child of a child and so on
So this looks like a bug, right?
module test; import tango.io.Stdout; import tango.text.xml.Document; import tango.io.File; char[] xml = " <p> <c> <c/> <c/> </c> <c> <c/> <c/> </c> </p> "; void main() { auto doc = new Document!(char); doc.parse(xml); auto p = doc.query["p"].nodes[0]; Stdout.formatln( // Prints 6 "doc.query[].descendant(\"c\").count = {}", doc.query[].descendant("c").count); Stdout.formatln( // Prints 2 "p.child(\"c\").count = {}", p.query["c"].count); Stdout.formatln( // Prints 4 - Should be 6? "p.descendant(\"c\").count = {}", p.query[].descendant("c").count); }