string operations

  • Thread starter Thread starter graphicsxp
  • Start date Start date
G

graphicsxp

Hi,

I have to update a text field of a SQL table. For that I retrieve the
records in a dataset and I loop through the rows of the dataset. The
field is a very long text string that basically contains the source
code of html pages. I need to do the following on each record :

1. Find the <body> tag in the string. Problem is that the body tag
could look like:
<body onload="some func" ....> so I need to find <body and then the
next closing '<'.

2.Find the </body> tag in the string.

3. get rid of everything outside the <body></body> tags in order to
retain only the content of the html page.

How could I do that in vb.net ?
 
Hai,
You should be able to accomplish your task by using code like:
intbodytagstart = String.IndexOf("<body", intsearchstartlocation)
intbodytagend = string.indexOf(">", intbodytagStart)
intbodyend = string.indexOf("</body>", intbodytagend)
strbody = string.Substring(intbodytagend+1, intbodyend - intbodystart
-1)

Worth giving a try.
 
Hai,
You should be able to accomplish your task by using code like:
intbodytagstart = String.IndexOf("<body", intsearchstartlocation)
intbodytagend = string.indexOf(">", intbodytagStart)
intbodyend = string.indexOf("</body>", intbodytagend)
strbody = string.Substring(intbodytagend+1, intbodyend - intbodystart
-1)
Worth giving a try.


Brilliant ! It works perfectely. Thank you !
 
Hi,

I have to update a text field of a SQL table. For that I retrieve the
records in a dataset and I loop through the rows of the dataset. The
field is a very long text string that basically contains the source
code of html pages. I need to do the following on each record :

1. Find the <body> tag in the string. Problem is that the body tag
could look like:
<body onload="some func" ....> so I need to find <body and then the
next closing '<'.

2.Find the </body> tag in the string.

3. get rid of everything outside the <body></body> tags in order to
retain only the content of the html page.

How could I do that in vb.net ?

Could you throw it at an xml parser?
 
Back
Top