我试图在没有换行的网页上检索此文本:
<span class="listingTitle">888-I-AM-JUNK. Canada's most trusted BIG LOAD junk removal<br />specialist!</span></a>
我该怎么做?
这是我目前使用vb。
的当前代码Dim content As String = ""
Dim doc As New HtmlAgilityPack.HtmlDocument()
doc.Load(WebBrowser1.DocumentStream)
Dim hnc As HtmlAgilityPack.HtmlNodeCollection = doc.DocumentNode.SelectNodes("//span[@class='listingTitle']")
For Each link As HtmlAgilityPack.HtmlNode In hnc
Dim replaceUnwanted As String = ""
replaceUnwanted = link.InnerText.Replace("&", "&") '
replaceUnwanted = replaceUnwanted.Replace("'", "'")
replaceUnwanted = replaceUnwanted.Replace("See full business details", "")
content &= replaceUnwanted & vbNewLine
Next
RichTextBox1.Text = content
Me.RichTextBox1.Lines = Me.RichTextBox1.Text.Split(New Char() {ControlChars.Lf}, _
StringSplitOptions.RemoveEmptyEntries)
我需要删除<br />
答案 0 :(得分:0)
如何进行相同的常规字符串操作?
replaceUnwanted = replaceUnwanted.Replace(vbCrLf, "")
如果您正在处理<span>...<span>
:
replaceUnwanted = replaceUnwanted.ToLower().Replace("<br>", "")
replaceUnwanted = replaceUnwanted.ToLower().Replace("<br />", "")