How can I select only the first following sibling?

UltimatePeter

Using XPATH, I am trying to get just the ISBN number out of the following:

<span class="product_info_details">
   <b class="">ISBN: </b>1941529429
   <b class="">Contributors: </b> (Illustrator)
   <b class="">Publisher:</b> Parallax Pr
   <b class="">Published:</b> Nov 1 2016
</span>

Now, when I use:

//span[@class="product_info_details"]/b/following-sibling::text()

I get the output:

1941529429

(Illustrator)

Parallax Pr

Nov 1 2016

What can I use so that I just get the first value (1941529429) as the result?

har07

You want to limit b element that the XPath find to the one that contains substring 'ISBN', and limit the following sibling text node to the nearest only :

//span[@class="product_info_details"]/b[contains(.,'ISBN')]/following-sibling::text()[1]

Alternatively, you can limit b element that the XPath find to the one that starts with substring 'ISBN' :

..../b[starts-with(.,'ISBN')]/....

Using position index 1, as mentioned on the other answer, should also work given the order of the b elements is consistent, but the two alternatives given above represents your intention better as it mentioned the substring 'ISBN' on which you based your search criteria to find the target text.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do i select sibling Elements in AngularJS

How to select following siblings until a certain sibling

Xpath: first preceding and following sibling

how can i share function of one sibling to another sibling component

How can I match only the first N instances of a pattern, then print lines following each pattern until a blank line?

how can i select the sibling ::after pseudo element when input:focus

How can I select the child of a sibling by XPath using Selenium?

How to use XPath to select following-sibling?

How can I select a checkbox in a sibling div using JQuery selectors?

how can I select only the dates?

How do I select preceding sibling Xpath

On hover of any element how can I select all sibling elements using CSS3 selector?

If I hover over an element, how can I select all sibling elements before it and including it, in jQuery?

Get the first following div sibling

How can I select first N elements?

Using XPath, how do I select only the links that have a particular child present under the links sibling element

How can I get either radio option in a group, to select sibling (hidden) checkboxes?

XPath how to select an element where the following sibling has an specific child?

How can I do a select following a select in LINQ

How can I get only first childnode?

On array How can i select only column

Xpath: select preceding and following sibling

xpath - How to select following siblings having only classname and child text elements but not knowing order and text of the following sibling?

Only select the first sibling element with a conditional check

How can I convert the code in the following select tags into a radio button?

How can I select the ::before of a sibling element with css?

How can I select only the first 3 children of an element?

How can I select only the first 3 element and not to last 3 element?

How can i select only one li?