views:

98

answers:

1

Hi guys, im trying to retrieve this text on a webpage without the line break:

<span class="listingTitle">888-I-AM-JUNK. Canada's most trusted BIG LOAD junk removal<br />specialist!</span></a>

How can I do it?

Here is my current code so far, im using 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)

I need to remove the <br />

A: 

How about going through the same regular string manipulation?

replaceUnwanted = replaceUnwanted.Replace(vbCrLf, "")

If you were dealing with the <span>...<span>:

replaceUnwanted = replaceUnwanted.ToLower().Replace("<br>", "")
replaceUnwanted = replaceUnwanted.ToLower().Replace("<br />", "")
p.campbell
Thanks a ton p.cambell, "replaceUnwanted = replaceUnwanted.ToLower().Replace(vbCrLf, "")" did the trick. I dont know how I didnt think of that.
Datadayne
@Datadayne: you bet, my pleasure. Obviously the toLower() doesn't really buy you anything with the vbCrLf case, but I'd just copy/pasted from the BR example. I've made the edit just for fun. Here's an upvote for your question!
p.campbell