load HTML as string (not file) into DOM to manipulate

Last post 05-16-2008 10:50 PM by SGWellens. 1 replies.

Sort Posts:

  • load HTML as string (not file) into DOM to manipulate

    05-16-2008, 5:20 PM
    • Loading...
    • sirafs
    • Joined on 05-16-2008, 9:12 PM
    • Posts 1

    I need to modify a section of HTML that will be submitted by a UI as a snippet (not as a file). I need to do some heavy reformatting of the HTML by identifying patterns of formatting in each node to determine what kind of content it is. It will be XHTML so I don't have to deal with poorly formed HTML.

     I have created basic data-driven asp.net pages, but have not used the DOM before. All of the examples I can find require loading a file or using the web browser control in a windows forms application. Just getting suggestions for a better set of search terms might help.

     THANK YOU

    Filed under: , ,
  • Re: load HTML as string (not file) into DOM to manipulate

    05-16-2008, 10:50 PM
    Answer
    • Loading...
    • SGWellens
    • Joined on 01-02-2007, 9:27 PM
    • MN, USA
    • Posts 3,388
    • Moderator
      TrustedFriends-MVPs

    You may be able to use the XmlDocument class:

            XmlDocument XDoc = new XmlDocument();
            XDoc.LoadXml("<HTML> <HEAD> <TITLE>Test Links</TITLE> </HEAD><BODY></BODY></HTML>");
    

     

    From the online help:

    This class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document and enables the navigation and editing of this document.

    Steve Wellens
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter