Paul
Mon Aug 01 17:48:19 CDT 2005
Hi, Joe
I'm trying to understand this HtmlFile class.
I'm partly confused because when I ask TLViewer or regedit to look for
"htmlfile", they lead me to something that came with a cheapo HP scanner.
Hpodxml.HTMLFile, for creating a 'memories disk'.
Is it basically a closed window that has navigated to about:blank, gives
full access to the dhtml object model and which completely exits memory when
the whole script or function ends, with no need for some kind of a quit
command?
I modified your JScript to test my theory:
Option Explicit
Dim oDoc, sHTML, colParas, ParagraphElement, oParentWindow
Set oDoc = CreateObject("htmlfile")
sHTML = "<html><head><title>Test</title></head><body>" & _
"<p>False paragraph</p>" & _
"<p class=""content"">Target paragraph</p>" & _
"</body></html>"
'Put your ResponseText into sHTML
oDoc.open()
oDoc.write(sHTML)
Set oParentWindow = oDoc.ParentWindow
MsgBox "TypeName(oDoc) = " & TypeName(oDoc) & vbCrLf & _
"TypeName(oParentWindow) = " & TypeName(oParentWindow) & vbCrLf & _
"oParentWindow.Status = " & oParentWindow.Status & vbCrLf & _
"oParentWindow.location.href = " & oParentWindow.location.href & vbCrLf & _
"oParentWindow.closed = " & oParentWindow.closed
oDoc.close()
Set colParas = oDoc.getElementsByTagName("p")
For Each ParagraphElement In colParas
If lCase(ParagraphElement.className) = "content" Then
WScript.echo(ParagraphElement.innerHTML) 'or innerText
End If
Next 'ParagraphElement
MsgBox oDoc.documentElement.outerHTML
I still don't know if it needs some kind of a quit command.
-Paul Randall
"Joe Fawcett" <joefawcett@newsgroups.nospam> wrote in message
news:On4WjuFlFHA.3568@tk2msftngp13.phx.gbl...
> "Paul Randall" <paulr901@cableone.net> wrote in message
> news:%23yoLiR$jFHA.576@tk2msftngp13.phx.gbl...
> > Hi, Bertrand
> > I use the Internet Explorer Document Object Model to get stuff from the
web.
> > Google:
> >
http://groups-beta.google.com/groups?q=readystate%20group:*.scripting&num=10
> > 0&scoring=d
> >
> > Microsoft has lots of good info:
> > There are subtle differences between the various object models and
sometimes
> > you have to look through a number of them for what you want.
> >
> >
http://search.microsoft.com/search/results.aspx?qu=HTML+and+DHTML+Reference&
> > View=msdn&st=b&c=0&s=1&swc=0
> >
> >
http://search.microsoft.com/search/results.aspx?view=msdn&st=b&na=82&qu=WebB
> > rowser+Object&s=1
> >
> >
http://search.microsoft.com/search/results.aspx?view=msdn&st=b&na=82&qu=Inte
> > rnetExplorer+Object&s=1
> >
> > -Paul Randall
> >
> > "Bertrand" <Bertrand@discussions.microsoft.com> wrote in message
> > news:A7FEDCB5-2F7E-4384-88E2-FB13E0911E83@microsoft.com...
> >> Hi,
> >>
> >> I need to download and pars data from an HTML page from the web. I have
> >> tried to use MSHTML but i cant create the HTMLDocument object. Any
ideas
> > on
> >> how to accomplish this in vbscript?
> >>
> >> Thanks,
> >> Bertrand
> >
> I would normally recommend using msxml2.xmlhttp.4.0 to retrieve the data
and
> HtmlFile class to create an in-memory document. The problem with
automating IE
> is that it runs the scripts it finds. I've posted a few times on both
these
> topics if you search Google groups.
> --
>
> Joe (MVP)
>
>
https://mvp.support.microsoft.com/profile=8AA9D5F5-E1C2-44C7-BCE8-8741D22D17
A5
>
>
>