Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XPath search for all text nodes, not the inner text of any other child node

I'm using HtmlAgilityPack.

I hover over the parent node and its ChildNodes show several #text nodes. The XPath value shows /code[1]/#text[1]. I try to use //#text to get all the text nodes but I get that error:

Error: Expression must evaluate to a node-set.

I've tried //text and get nothing, but no error.

like image 721
Chuck Savage Avatar asked May 20 '11 21:05

Chuck Savage


1 Answers

You need to use text() to get text nodes. To get all text nodes in the document, use //text().

From the specification:

text() matches any text node.

like image 108
lonesomeday Avatar answered Oct 14 '22 07:10

lonesomeday