Get innertext between two tags - VB.NET - HtmlAgilityPack

懵懂的女人 提交于 2019-12-22 11:05:54

问题


I'm using HtmlAgilityPack and I want to get the inner text between two specific tags, for example:

<a name="a"></a>Sample Text<br>

I want to get the innertext between </a> and <br> tags: Sample Text

How can I do it?

TIA...


回答1:


Once you have reached the anchor you could use the NextSibling property:

Dim doc = New HtmlDocument()
doc.LoadHtml("<html><body><a name=""a""></a>Sample Text<br></body></html>")
Dim a = doc.DocumentNode.SelectSingleNode("//a[@name=""a""]")
Console.WriteLine(a.NextSibling.InnerText)


来源:https://stackoverflow.com/questions/7291644/get-innertext-between-two-tags-vb-net-htmlagilitypack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!