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

Hi,
you specify, what method you are using to Scrape the Page . Have you heard Regex class?

Regex is a Class that used for Regular Expressions. It is useful for Parsing.

For more detail, refer http://www.regular-expressions.info/dotnet.html

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

Member Avatar for iamthwee

Ever heard of Trim(). Use it!

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

Member Avatar for iamthwee

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 .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.