How to process HTML pages on server side with HTML DOM?

Discussion in 'ASP General' started by Vince C., Jan 5, 2004.

  1. Vince C.

    Vince C. Guest

    Hi.

    I'd like to process HTML documents in an ASP script, i.e. to remove any unwanted
    elements and extract desired element and attributes. I know how to do it on
    client side within IE using its HTML DOM. But what I'd like is to do it
    server-side. Is there a way, for instance, to reuse MSIE technology to retrieve
    interfaces like IHTMLElement, IHTMLDOMAttribute, aso, or just built-in features
    that would allow me to do the same?

    Thanks or any hint/suggestion.

    Vince C.
     
    Vince C., Jan 5, 2004
    #1
    1. Advertising

  2. Hi Vince,

    Thanks for posting in the group.

    Currently I am finding somebody who could help you on it. We will get back
    here with more information as soon as possible. If you have any more
    concerns, please feel free to post here.

    Best regards,
    Yanhong Huang
    Microsoft Community Support

    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Yan-Hong Huang[MSFT], Jan 5, 2004
    #2
    1. Advertising

  3. Vince C.

    MSFT Guest

    Hi Vince,

    As I understabd, you want to parse the DOM element for a HTML file in ASP
    server script. To achieve this, we may read the HTML file with FSO and Load
    it in a HTMLDocument object, for example:

    <%@Language=VBScript CODEPAGE=65001 %>

    <%

    Dim doc

    Set doc = CreateObject("HTMLFILE")

    dim objFSO

    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

    dim htmlFile

    set htmlFile= objFSO.OpenTextFile("c:\test.html")


    doc.write htmlFile.ReadAll

    'doc.body.innerText="hello world"

    Response.Write doc.documentElement.outerHTML

    %>

    Hope this answer your question,

    Regards,

    Luke
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    MSFT, Jan 6, 2004
    #3
  4. Vince C.

    Vince C. Guest

    "MSFT" <> a écrit dans le message de
    news:...
    > Hi Vince,
    >
    > As I understabd, you want to parse the DOM element for a HTML file in ASP
    > server script. To achieve this, we may read the HTML file with FSO and Load
    > it in a HTMLDocument object, for example:
    >
    > <%@Language=VBScript CODEPAGE=65001 %>
    >
    > <%
    >
    > Dim doc
    >
    > Set doc = CreateObject("HTMLFILE")
    >
    > dim objFSO
    >
    > Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    >
    > dim htmlFile
    >
    > set htmlFile= objFSO.OpenTextFile("c:\test.html")
    >
    >
    > doc.write htmlFile.ReadAll
    >
    > 'doc.body.innerText="hello world"
    >
    > Response.Write doc.documentElement.outerHTML
    >
    > %>
    >
    > Hope this answer your question,


    Oh my! I never thought it was so simple! Knocks one's socks off... It was worth
    asking the question before reinventing the wheel.

    Not even threading nor performance issues apart from those that relate to using
    FSO? Note you don't need to say "yes" as I'm already satisfied ;-).

    Vince C.
    "- Use the forge, Luke..."
     
    Vince C., Jan 6, 2004
    #4
  5. Vince C.

    MSFT Guest

    Hi Vince,

    For frequently requested web page, we need to consider the performance for
    FSO. Anyway, FSO is the common way we use in ASP to read a file.

    Luke
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    MSFT, Jan 7, 2004
    #5
  6. Vince C.

    Pete Guest

    Or, if your html is xml-compliant, you can always use the XML Parser.



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Pete, Jan 7, 2004
    #6
  7. Vince C.

    Vince C. Guest

    "Pete" <> a écrit dans le message de
    news:%...
    > Or, if your html is xml-compliant, you can always use the XML Parser.


    That's my problem: it's not. Because modified (for now) by non XHTML-aware
    Office tools.

    Vince C.
     
    Vince C., Jan 7, 2004
    #7
    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. Mythran
    Replies:
    2
    Views:
    545
    Mythran
    Jan 22, 2005
  2. Joey
    Replies:
    1
    Views:
    817
    =?Utf-8?B?aGVpbg==?=
    Jan 3, 2006
  3. Thor
    Replies:
    1
    Views:
    1,044
    Mikkel Heisterberg
    Jul 2, 2003
  4. Replies:
    0
    Views:
    484
  5. Replies:
    1
    Views:
    680
    Kevin Spencer
    Oct 31, 2006
Loading...

Share This Page