Jump to content

getElementsByClassName doesn't work


Recommended Posts

Hi!

Does anyone have any idea why Test() returns 0, while Test2() returns 1?

#include <IE.au3>

MsgBox(0, "", Test() & " " & Test2())

Func Test()
    Local $oHTML = ObjCreate("HTMLFILE")

    $oHTML.body.innerHTML = FileRead("Test.html")

    Return IsObj($oHTML.getElementsByClassName("example"))
EndFunc

Func Test2()
    Local $oIE = _IEAttach("", "instance", 1)

    Return IsObj($oIE.document.getElementsByClassName("example"))
EndFunc

Sample Test.html I open in IE before testing:

<!DOCTYPE html>
<html>
    <body>
        <p class="example"></p>
        <div class="example"></div>
    </body>
</html>

I'm receiving html text in a response to http request, I need to parse it fast and easy, getElementsByClassName would have been ideal. I'm using 3.3.12.0 version.

Edited by mjolnirmarkiv
Link to comment
Share on other sites

It seems you cannot use getElementsByClassName with an HtmlFile object.

You can try MSXML2.XMLHttp instead

Edit : also with _IE functions

Edited by jguinch
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...