Home > Net >  How to get the relative xpath for HTML
How to get the relative xpath for HTML

Time:07-08

In below i need to get the value '1' with reference of Class name.

<span><span ></span>1<span 

I tried below xpath ="(//span[@class='ml-5']//following-sibling::text())" but its not recognized as web element

CodePudding user response:

You can try this

//span[@class='ml-5']/..

CodePudding user response:

This XPath found the expected text
//span[./span[@class='ml-5']]/text()

xmllint --html --shell test.html 
/ > cat //span[./span[@class='ml-5']]/text()
 -------
1
  • Related