我需要检索一个html页面,然后隔离部分代码。
首先,我有大量的html。我需要找到这个:
<div class="XP_points">Anything here.</div>并拥有
<div class="XP_points">9,775</div>放入另一个字符串。我可以从那里接手。
发布于 2011-12-11 02:22:24
string text= sourcetext
text = System.Text.RegularExpressions.Regex.Split(text , "XP_points""">")(1)
string sig1 = text
sig1 = sig1.IndexOf("<", 1)
text = text.Remove(sig1, text.Length - sig1)
sourcetext=sourcetext.Replace(text,"9,775")发布于 2011-12-11 01:13:15
听起来您需要Html Agility Pack,它提供了丰富的功能来查询和更改HTML。
发布于 2011-12-11 01:20:23
我建议使用正则表达式来搜索数据,并将其替换为您想要的内容。
从这里开始学习如何在VB.Net中使用正则表达式
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.matchcollection.item.aspx#Y0
在正则表达式示例中查找匹配的HTML标记
http://www.regular-expressions.info/examples.html
https://stackoverflow.com/questions/8458278
复制相似问题