Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Instantiate MSHTML and Parse/modify the DOM?
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Instantiate MSHTML and Parse/modify the DOM?
Divers
Thread ID:
00910310
Message ID:
00910310
Vues:
80
I need to programmatically parse and modify snippets of HTML on the fly using the DOM. I would like to do it invisibly and efficiently, i.e., just a parser to give me the DOM the way MSXML does for XML. It seems that MSHTML provides the capabilities to do that, but I have not been able to determine if it has a COM interface compatible with VFP. I need something like:
oParser=CreateObject("MSHTML.HTMLDocument")
cHTMLDocument="<HEAD></HEAD><BODY>" + cMyHTMLSnippet + "</BODY></HTML>"
oParser.DocumentHTML=cHTMLDocument    
&&  ... Wait for not busy, then...
nImages=oParser.Document.DOM.Images.Length
&& ...Do something with each image element, such as set height and width attribs
For i=0 to nImages-1
  oThisImage=oParser.Document.DOM.Images[i]
  etc...
Endfor
&& ... Extract the modified HTML (document.body.innerHTML)
cNewHTML=oParser.Document.DOM.body.innerHTML
I can do this, and have it working, by using the DHTMLEdit control and driving it programmatically, but it seems to insist on being instantiated as a form-based control in order to operate. So I have this unnecessary form creation/destruction (and hiding issues). Isn't there a better way? Thanks for any suggestions!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform