Jump to content
Sign in to follow this  
jdelaney

IEDom.Attributes returns more than expected IE9.0

Recommended Posts

jdelaney

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.

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
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
Sign in to follow this  

×