Hi,

I'm doing a screen scrape of a web page, which works with out any problems

What I want to do is replace the contents of tag, I can do this if the tag match exactly but in this page there are allot of blank spaces.

lbltest.Text contains the page being scrapped. The tag is formatted like this

<li class="thisclass">
			   
			     TheText
			   
             </li>

I can't to a simple replace because of all the spaces. So I need to get it to look like this

<li class="thisclass">TheText</li>

Any ideas how I might do this?

Thanks in advance

Ever heard of Trim(). Use it!

I think you have missed the point, I need to replace line breaks and spaces, if you look at the example given, trim will not do this

Incorrect, trim does replace line breaks and spaces. Please prove me wrong but you won't.

I have just tested it:

Dim nl As String = System.Environment.NewLine
Dim test As String = "                   " + nl + nl + "     TheText  " + nl + nl


TextBox1.Text = test   'show original string in a multiline text box
TextBox2.Text = test.Trim 'show changed string in a multiline text box

thanks, how would I pick up on the line breaks and spaces, would it be possile to show me an example?

Hi,

Please google it for parsing HTML using Regex class. You will get a lot. Once you can able to parse HTML Tags, Ultimately you have to Use String.Trim() to remove unwanted white spaces .

This article has been dead for over six months. Start a new discussion instead.