Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Stripping content delimited by two tags

Reply
Thread Tools

Stripping content delimited by two tags

 
 
Ken Fine
Guest
Posts: n/a
 
      02-05-2004
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


 
Reply With Quote
 
 
 
 
Ryan N.
Guest
Posts: n/a
 
      02-05-2004
Well...you could use Regular Expressions or a combination of INSTR and MID.

--
Cheers!

Ryan N.
---------------------------------
Funny...this worked yesterday....

"Ken Fine" <(E-Mail Removed)> wrote in message
news:bvue3g$jbu$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      02-05-2004
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" <(E-Mail Removed)> wrote in message
news:bvue3g$jbu$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Ken Fine
Guest
Posts: n/a
 
      02-05-2004
Thanks again, Ray.

-KF


"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:bvue3g$jbu$(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Manohar Kamath [MVP]
Guest
Posts: n/a
 
      02-05-2004
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 <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:bvue3g$jbu$(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      02-05-2004
As Manohar pointed out, what I posted is just one way of many though!

Ray at work


"Ken Fine" <(E-Mail Removed)> wrote in message
news:bvui8j$fe6$(E-Mail Removed)...
> Thanks again, Ray.
>
> -KF
>
>
> "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
> message news:%(E-Mail Removed)...
> > iStart = InStr(theSource, "<contentarea>")
> > iStop = InStr(theSource, "</contentarea>")
> >
> > sContent = Mid(theSource, iStart + Len("<contentarea>"), iStop -

iStart -
> > Len("</contentarea>") + 1)
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert non-delimited to delimited RyanL Python 6 08-28-2007 12:06 AM
Stripping html tags from text Spondishy ASP .Net 4 03-07-2006 03:45 PM
Stripping HTML attributes and tags JJ Harrison HTML 5 11-28-2005 10:12 PM
stripping tags from source on render Lance ASP .Net 4 06-17-2005 05:32 PM
stripping HTML tags shank ASP General 3 07-14-2004 11:55 AM



Advertisments