Xpath - finding sibiling

I want to find the parent and the sibiling of some nodes in a website (it xpath). My big problem is that I want to find a sibiling of node, with no Id, only by it attribute.

for example: <a id="nav-europe-3231" class="" href="/EUROPE/" title="Europe News Headlines and Video from CNN.com International">Europe</a>

 <a id="nav-asia-1265" class="" href="/ASIA/" title="Asia News Headlines and Video from CNN.com International">Asia</a>

I saw some instruction, like parent::child-node, but it doesn't find the xpath in this way.

How can I find the parents and the sibiling of this node?

Answers


In XPath 1 you can find the siblings and parent of the context node via the preceding-sibling:: and following-sibling:: axes (for siblings) and either ../ or theparent::` axe to find the parent.

Note that with axes you must specify a node name after the ::. If you don't know it, you can use the wildcard, *.

See http://www.w3schools.com/xpath/xpath_axes.asp


Need Your Help

Could not access memory under C++ vector

c++ gdb g++ stdvector

I'm using a vector in my program like this:

How can I build multiple products with different dependency versions in Visual Studio?

c++ visual-studio-2010

I'm building a Ruby C Extensions and I have to build for both Ruby 1.8 and Ruby 2.0. The source code is the same, but I have to link to different Ruby libs and set different build paths.