ASP.NET + VB.NET - How to get a value from a HTML string
How do I get the value from a HTML strin开发者_开发知识库g using VB.NET?
<p style="text-align: center; margin: 0px">
<span style="font-family: tahoma,arial,helvetica,sans-serif; font-size: 12pt; font-weight: bold">
This is the text I want to catch!!!
</span>
</p>
Use an HTML parser such as the HTML Agility Pack.
It can parse both full documents and document fragments and let you query these using XPath like syntax.
The source download comes with many example projects.
1- Turn the span to a server object:
<span ID="span1" runat="server"> .... </span>
2- InnerText property to get the text reside inside the span between > and < :
Dim str as string = span1.InnerHTML
精彩评论