删除htmlagilitypack中的换行节点?

时间:2010-09-10 22:39:23

标签: vb.net html-agility-pack

我试图在没有换行的网页上检索此文本:

<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("&amp;", "&") '
            replaceUnwanted = replaceUnwanted.Replace("&#39;", "'")
            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 />

1 个答案:

答案 0 :(得分:0)

如何进行相同的常规字符串操作?

replaceUnwanted = replaceUnwanted.Replace(vbCrLf, "")

如果您正在处理<span>...<span>

replaceUnwanted = replaceUnwanted.ToLower().Replace("<br>", "")
replaceUnwanted = replaceUnwanted.ToLower().Replace("<br />", "")