Parse HTML with mshtml

modularbeing

Regular
Joined
Jan 8, 2004
Messages
63
Hello,
I am pulling a stream of html from a webservice and I need to replace some image tags with another control. I originally was going to parse this as a string using instr() but I was looking at the mshtml assembly and thought that this might work better for me. I wrote some code that looks like it will find all the IMG tags and put them into the IHTMLElementCollention. once I have found all the image tags, is there a way I can use mshtml to replace those tags with web controls? previously I was using
Code:
MyBase.Controls.Add(chkSignature(0))
to add a web control but I do not know if I can do this with mshtml.

This is the code that I have so far to search for the IMG tags in the document, I have not tested it yet.

Code:
        Dim HTMLContent As New HTMLDocument
        HTMLContent = DirectCast(strContent, HTMLDocument)
        Dim colHTMLElements As IHTMLElementCollection = HTMLContent.getElementsByTagName("IMG")
        Dim HTMLElement As IHTMLElement

        For Each HTMLElement In colHTMLElements
            'Replace Image tags
        Next
Thanks
 
What namespace is "HTMLDocument", "DirectCast", and "IHTMLElementCollection" part of ?

i was going to mess around with it to help you out, but can't find what part of the framework it is
 
HTMLDocument and IHTMLElementCollection are part of mshtml which needs a reference added to the project, it should be listed under 'Microsoft.mshtml' in the .Net tab of the add reference screen. The DirectCast function is part of vb. thanks
 
ugg.. actually you are looking to replace the HTML with a Server-based control?

that doesn't seem feasible unless you wrap the added controls with Literal controls holding the text around the image tags....

if that's not a solution, it is out of my skill level unfortuantely
 
Back
Top