Neighboring Siblings?

Found an Interesting observation on C.M.Spielberg McQueen’s Blog – XPath 1.0 describes, amongst other axes, ones that allow access to immediate parent and immediate child nodes, as well as access to ancestor and descendant node-sets, but does not provide for immediate siblings – The only way to access these are via predicates – preceding-sibling::*[1] or following-sibling::*[1], and not explicit next-sibling and a previous-sibling axes.

Join the discussion

Comments ( 1 )

guest Monday, October 24, 2011

And there is no "sibling-or-self" axis, such as for example "following-sibling-or-self" - which causes problems when you are trying to find a certain node and its following siblings.

A work-around that works when there are preceding siblings (not part of the match) is to move to the immediate preceding sibling before doing a following-sibling call. But, of course, when there are no such preceding siblings, you can't use that technique.