[dba-SQLServer] Decoding HTML in SQL Server Table

MartyConnelly martyconnelly at shaw.ca
Wed Jan 26 02:03:43 CST 2005


You could try regular expression if you know exactly what you want to 
parse out
If the HTML is XHTML compliant you could use XSLT

Or you could try the mshtml parser but there is no telling if your html 
is w3c compliant.

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/hosting.asp

This is  documented in IE SDK

Your code must have a reference to the Microsoft HTML Object Library. 
mshtml.dll
 Internet Explorer 5 or more is required to do this. Sample code

Dim objLink As HTMLLinkElement
Dim objMSHTML As New MSHTML.HTMLDocument
Dim objDocument As MSHTML.HTMLDocument
' This function is only available with Internet Explorer 5 and up

Set objDocument = objMSHTML.createDocumentFromUrl(txtURL.Text, _
                                                  vbNullString)

While objDocument.readyState <> "complete"
    DoEvents
Wend

' Source Code

Debug.Print = objDocument.documentElement.outerHTML

' Title

Debug.Print "Title : " & objDocument.Title

'  grab a Link Collection from html

For Each objLink In objDocument.links
    lstLinks.AddItem objLink
    Debug.Print "Link:  " & objLink
Next


Susan Geller wrote:

>Well, after searching around for a long time, I finally decided it would
>be easier to do something more manual. This one line of sql in my sproc
>gets most of the job done:
>
>Select replace(replace(replace (my_field_name, '>' , '' ), '"',
>''), '<', '') 
>>From my_table
>
>I'm still open to ideas if anybody has them.
>
>--Susan
>
>
>
>-----Original Message-----
>From: dba-sqlserver-bounces at databaseadvisors.com
>[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Susan
>Geller
>Sent: Tuesday, January 25, 2005 1:44 PM
>To: dba-sqlserver at databaseadvisors.com
>Subject: [dba-SQLServer] Decoding HTML in SQL Server Table
>
>I am trying to create a report in Access using data in SQL Server.  The
>data is written to SQL Server through a c#.net application. The
>application stores the data for one field encoded with html so I have
>text that looks like this:
>
>>Subject: RE: my program
>>Date: Thu, 30 Dec 2004 09:25:12 -0600 > >Hi Janelle, > 
>
>I want to decode the html and make it look like straight text when it
>appears in my Access report.  I can't figure out how to do it either in
>SQL Server or in Access.  Ideas anybody?
>
>Thanks.
>
>--Susan
>
>
>Susan B. Geller
>Office of Information Systems
>College of Continuing Education
>University of Minnesota
>306 Wesbrook Hall
>77 Pleasant Street SE
>Minneapolis, MN 55455
>Phone:  612-626-4785
>Fax:  612-625-2568
>
>
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the dba-SQLServer mailing list