Stripping content delimited by two tags

Discussion in 'ASP General' started by Ken Fine, Feb 5, 2004.

  1. Ken Fine

    Ken Fine Guest

    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
    Ken Fine, Feb 5, 2004
    #1
    1. Advertising

  2. Ken Fine

    Ryan N. Guest

    Well...you could use Regular Expressions or a combination of INSTR and MID.

    --
    Cheers!

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

    "Ken Fine" <> wrote in message
    news:bvue3g$jbu$...
    > 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
    >
    >
    Ryan N., Feb 5, 2004
    #2
    1. Advertising

  3. Ken Fine

    Ray at Guest

    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" <> wrote in message
    news:bvue3g$jbu$...
    > 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
    >
    >
    Ray at, Feb 5, 2004
    #3
  4. Ken Fine

    Ken Fine Guest

    Thanks again, Ray.

    -KF


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

    >
    >
    Ken Fine, Feb 5, 2004
    #4
  5. 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:%...
    > 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" <> wrote in message
    > news:bvue3g$jbu$...
    > > 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
    > >
    > >

    >
    >
    Manohar Kamath [MVP], Feb 5, 2004
    #5
  6. Ken Fine

    Ray at Guest

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

    Ray at work


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

    iStart -
    > > Len("</contentarea>") + 1)
    > >
    Ray at, Feb 5, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lance
    Replies:
    4
    Views:
    421
    Lance
    Jun 17, 2005
  2. Spondishy

    Stripping html tags from text

    Spondishy, Mar 6, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    4,143
    m.posseth
    Mar 7, 2006
  3. JJ Harrison

    Stripping HTML attributes and tags

    JJ Harrison, Nov 27, 2005, in forum: HTML
    Replies:
    5
    Views:
    1,303
    Toby Inkster
    Nov 28, 2005
  4. RyanL
    Replies:
    6
    Views:
    666
    Paul McGuire
    Aug 28, 2007
  5. shank

    stripping HTML tags

    shank, Jul 10, 2004, in forum: ASP General
    Replies:
    3
    Views:
    103
    Alex Kail
    Jul 14, 2004
Loading...

Share This Page