How can I select links without id or class attributes using XPath?
I want to select number 4 or 5 links
i have tried using this expression:
//div/b[contains(text(),'Sida:')]/following-siblings::a[4]
but it didnt work
The code for this part of my HTML is:
<div><b>Sida: </b> <a>1</a> « <a>3</a> <a>4</a> <开发者_如何学编程a>5</a> » <a>814</a></div>
Here is how its looks
http://i.stack.imgur.com/rFmug.jpg Sida: 1 2 3 4 » 814or
Sida: 1 « 3 4 5 » 814there are a long html page without any id or class name - so i need autopager in firefox to find the correct link <a>
and automatically auto inert next page
i just need the expression to pinpoint the number 4 or 5 - but these number are changing when page number are changing
check the web page l-like.it
You almost did it yourself.
To get a node-set of two elements (which can be not what you want) you can use this:
//div/b[contains(text(),'Sida:')]/following-sibling::a[
position() = 3 or position() = 4
]
Note: Use //
only when schema is unknown.
To get a concatenated string value:
concat(
//div/b[contains(text(),'Sida:')]/following-sibling::a[3],
//div/b[contains(text(),'Sida:')]/following-sibling::a[4]
)
Output with the input below will be 45
.
XML test sample:
<t>
<div>bla-bla</div>
<div id="test">
<div>
<b>Sida: </b>
<a>1</a> «
<a>3</a>
<a>4</a>
<a>5</a> »
<a>814</a>
</div>
</div>
<div>bla-bla</div>
</t>
精彩评论