Jump to content

IEDom.Attributes returns more than expected IE9.0


Recommended Posts

Launch an IE 9@ google.com, and then run the following...

#include <IE.au3>
#include <Array.au3>
$oObj = _IEAttach("google")
$colNode = _IETagNameGetCollection ( $oObj, "input" )
For $Node In $colNode
MsgBox ( 4096, "test", $Node.attributes.length & " " & $Node.outerhtml)
$colAttr = $Node.attributes
Dim $aitests[$colAttr.length][4]
For $Attr in $colAttr
  $aitests[$i][0] = $Attr.Name
  $aitests[$i][1] = $Attr.Value
  $aitests[$i][2] = $Attr.NodeName
  $aitests[$i][3] = $Attr.NodeValue
  ;msgbox ( 4096, "test", "colNode.length=" & $colNode.Length & "  colAttr.length=" & $colAttr.length & "  Attr.nodename=" & $Attr.NodeName & "  Attr.nodevalue=" & $Attr.NodeValue & "  Attr.name=" & $Attr.Name &  "  Attr.Value=" & $Attr.Value )
Next
_ArrayDisplay ( $aitests )
Next

The first message box will show there are only 2 attributes...but then, actually getting the .attributes of each node results in over 100 returns. Anyone sure why? And those that are returned, none match what are in the actual attributes.

The .attributes works fine on XMLdom objects.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

haha, you solved my issue, thanks. I happened to have an $i declared (above the piece i copied in), so it worked, but did not reutrn what was expected...fixed:

#include <IE.au3>
#include <Array.au3>
$oObj = _IEAttach("google")
$colNode = _IETagNameGetCollection ( $oObj, "input" )
For $Node In $colNode
MsgBox ( 4096, "test", $Node.attributes.length & " " & $Node.outerhtml)
$colAttr = $Node.attributes
Dim $aitests[$colAttr.length][4]
$i = 0
For $Attr in $colAttr
  $aitests[$i][0] = $Attr.Name
  $aitests[$i][1] = $Attr.Value
  $aitests[$i][2] = $Attr.NodeName
  $aitests[$i][3] = $Attr.NodeValue
  ;msgbox ( 4096, "test", "colNode.length=" & $colNode.Length & "  colAttr.length=" & $colAttr.length & "  Attr.nodename=" & $Attr.NodeName & "  Attr.nodevalue=" & $Attr.NodeValue & "  Attr.name=" & $Attr.Name &  "  Attr.Value=" & $Attr.Value )
  $i = $i + 1
Next
_ArrayDisplay ( $aitests )
Next

Oh, and FYI, .attributes returns ALL possible attributes, and only includes values for those that have values.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...