I'm struggling trying to get the text information from a td node containing a link and raw text, as the example bellow.
<td>Statue of <a href="/wiki/Camille_Pelletan" title="Camille Pelletan">Camille Pelletan</a></td>
What is the best Xpath to extract "Statue of Camille Pelletan" together? Thanks!
答案 0 :(得分:3)
Using the XPath 1.0 string
function will return all of the text contained in descendants of the node. (If you pass in a nodeset, it will take only the first node in the set.)
If your example was the entire document, you could use this:
string(//td)
returns:
Statue of Camille Pelletan