Stripping content delimited by two tags

K

Ken Fine

Let's suppose I scrape the content of a remote page and stuff it in variable
strString.

And suppose the web person had the forsight to label a certain section of
the page content as follows

<contentarea>

[a bunch of content here]

</contentarea>

How could you use ASP string parsing functions to extract the content
between <contentarea> and </contentarea> from strString?

Thanks,
Ken
 
R

Ray at

iStart = InStr(theSource, "<contentarea>")
iStop = InStr(theSource, "</contentarea>")

sContent = Mid(theSource, iStart + Len("<contentarea>"), iStop - iStart -
Len("</contentarea>") + 1)

That would be a basic way to do it.

Ray at work
 
K

Ken Fine

Thanks again, Ray.

-KF


Ray at said:
iStart = InStr(theSource, "<contentarea>")
iStop = InStr(theSource, "</contentarea>")

sContent = Mid(theSource, iStart + Len("<contentarea>"), iStop - iStart -
Len("</contentarea>") + 1)

That would be a basic way to do it.

Ray at work


Ken Fine said:
Let's suppose I scrape the content of a remote page and stuff it in variable
strString.

And suppose the web person had the forsight to label a certain section of
the page content as follows

<contentarea>

[a bunch of content here]

</contentarea>

How could you use ASP string parsing functions to extract the content
between <contentarea> and </contentarea> from strString?

Thanks,
Ken
 
M

Manohar Kamath [MVP]

Ray,

Another way to do this would be to use two splits:

arFirst = Split(theSource, "<contentarea>")
content = Split(arFirst(1), "</contentarea>")(0)

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com


Ray at said:
iStart = InStr(theSource, "<contentarea>")
iStop = InStr(theSource, "</contentarea>")

sContent = Mid(theSource, iStart + Len("<contentarea>"), iStop - iStart -
Len("</contentarea>") + 1)

That would be a basic way to do it.

Ray at work


Ken Fine said:
Let's suppose I scrape the content of a remote page and stuff it in variable
strString.

And suppose the web person had the forsight to label a certain section of
the page content as follows

<contentarea>

[a bunch of content here]

</contentarea>

How could you use ASP string parsing functions to extract the content
between <contentarea> and </contentarea> from strString?

Thanks,
Ken
 
R

Ray at

As Manohar pointed out, what I posted is just one way of many though!

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top