Reputation: 1378
I am trying to get the inner text from a node but it has child nodes and its text is in the middle of its child entries i.e:
<script1>
<p1>lalala</p1>
"script text"
</script1>
The code I need is inside script1, but if I try and get innertext I get all of the inside of p1 too..
Cannot figure it out.
Upvotes: 1
Views: 1516
Reputation: 139316
This code:
HtmlDocument doc = new HtmlDocument();
doc.Load(MyTextHtml);
HtmlNode node = doc.DocumentNode.SelectSingleNode("//p1/following-sibling::text()");
Console.WriteLine(node.InnerText.Trim());
will output this:
"script text"
Here is link on XPATH axes that should get you started.
Upvotes: 1