asp innerText?

Discussion in 'ASP General' started by Giles, Feb 16, 2006.

  1. Giles

    Giles Guest

    in DHTML, body.innerText nicely strips out the raw textual contents of a
    formatted page. Is there a straighforwards way to do this with a server-side
    ASP function (e.g. on a string containing the HTML) ? It is to fill a
    database field used for a simple search routine.
    I don't have permission on this server to use 3rd party components, it's
    plain IIS6.
    Thanks.
    Giles
    Giles, Feb 16, 2006
    #1
    1. Advertising

  2. Giles wrote:
    > in DHTML, body.innerText nicely strips out the raw textual contents
    > of a formatted page. Is there a straighforwards way to do this with a
    > server-side ASP function (e.g. on a string containing the HTML) ? It
    > is to fill a database field used for a simple search routine.
    > I don't have permission on this server to use 3rd party components,
    > it's plain IIS6.


    Use a Regular Expression.
    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Feb 16, 2006
    #2
    1. Advertising

  3. Giles

    Giles Guest

    from Bob Barrows [MVP]
    > Giles wrote:
    >> in DHTML, body.innerText nicely strips out the raw textual contents
    >> of a formatted page. Is there a straighforwards way to do this with a
    >> server-side ASP function (e.g. on a string containing the HTML) ? It
    >> is to fill a database field used for a simple search routine.
    >> I don't have permission on this server to use 3rd party components,
    >> it's plain IIS6.

    >
    > Use a Regular Expression.
    > Bob Barrows


    RegExp is a black art to me! Off the top of the head,
    delete from "<head" to "/head>"
    delete from "<style" to "/style>" (in case not in head)
    delete from "<script" to "/script>" (in case not in head)
    replace anything in chevrons with nothing.
    replace line-breaks with spaces
    replace multiple spaces with single spaces
    replace HTML entities with literals
    Does that sound about right?
    thanks, Giles
    Giles, Feb 16, 2006
    #3
  4. Giles wrote:
    > from Bob Barrows [MVP]
    >> Giles wrote:
    >>> in DHTML, body.innerText nicely strips out the raw textual contents
    >>> of a formatted page. Is there a straighforwards way to do this with
    >>> a server-side ASP function (e.g. on a string containing the HTML) ?
    >>> It is to fill a database field used for a simple search routine.
    >>> I don't have permission on this server to use 3rd party components,
    >>> it's plain IIS6.

    >>
    >> Use a Regular Expression.
    >> Bob Barrows

    >
    > RegExp is a black art to me!

    Somewhat to me as well ...
    A couple people in this group (Chris Hohmann comes to mind) have it down
    pretty well. There are some websites out there that provide libraries of
    regular expression patterns.

    > Off the top of the head,
    > delete from "<head" to "/head>"
    > delete from "<style" to "/style>" (in case not in head)
    > delete from "<script" to "/script>" (in case not in head)
    > replace anything in chevrons with nothing.
    > replace line-breaks with spaces
    > replace multiple spaces with single spaces
    > replace HTML entities with literals
    > Does that sound about right?


    I guess so, but why are you leaving the closing and opening brackets?


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Feb 16, 2006
    #4
  5. Giles

    Justin Piper Guest

    Giles wrote:
    > in DHTML, body.innerText nicely strips out the raw textual contents of a
    > formatted page. Is there a straighforwards way to do this with a server-side
    > ASP function (e.g. on a string containing the HTML) ? It is to fill a
    > database field used for a simple search routine.


    If you can, you might consider using the Indexing Services instead of
    rolling your own search routine.

    http://www.codeproject.com/asp/indexserver.asp

    If that's not an option, you should be able to use Internet Explorer
    from an ASP.

    <% Option Explicit

    Dim ie: Set ie = CreateObject("InternetExplorer.Application")
    ie.Navigate "about:blank"

    Dim doc: Set doc = ie.Document
    doc.open
    doc.writeln "<dl>"
    doc.writeln "<dt>em</dt>"
    doc.writeln "<dd>Indicates <em>emphasis</em></dd>"
    doc.writeln "<dt>strong</dt>"
    doc.writeln "<dd>Indicates <strong>stronger emphasis</strong></dd>"
    doc.writeln "</dl>"
    doc.close

    Response.ContentType = "text/plain"
    Response.Write doc.documentElement.InnerText
    %>
    Justin Piper, Feb 16, 2006
    #5
  6. "Giles" <> wrote in message
    news:...
    > in DHTML, body.innerText nicely strips out the raw textual contents of a
    > formatted page. Is there a straighforwards way to do this with a
    > server-side ASP function (e.g. on a string containing the HTML) ? It is to
    > fill a database field used for a simple search routine.
    > I don't have permission on this server to use 3rd party components, it's
    > plain IIS6.


    With ASP you have complete control over the content of the page before it
    gets written so it's not clear to me why you would need to do this ...

    --
    Tom Kaminski IIS MVP
    http://www.microsoft.com/windowsserver2003/community/centers/iis/
    http://mvp.support.microsoft.com/
    http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
    Tom Kaminski [MVP], Feb 17, 2006
    #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. John A Grandy

    force line break inside .InnerText

    John A Grandy, Oct 17, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    6,931
    John A Grandy
    Oct 17, 2003
  2. martin

    innerText of xml doc

    martin, Mar 5, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    4,589
    martin
    Mar 6, 2004
  3. dw

    Write Panel's innerText

    dw, Sep 6, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    3,173
  4. =?Utf-8?B?THluZXJz?=

    innertext, javascript, datagrid, database update

    =?Utf-8?B?THluZXJz?=, Aug 19, 2005, in forum: ASP .Net
    Replies:
    13
    Views:
    6,844
    =?Utf-8?B?THluZXJz?=
    Aug 23, 2005
  5. Bob
    Replies:
    1
    Views:
    1,063
    Eliyahu Goldin
    Feb 20, 2008
Loading...

Share This Page