Jump to content

HTML DOM .attributes


Recommended Posts

Anyone know of the syntax to filter html down by attribute name/value in a single line?

Currently, first I search for a element by name, loop through that for a specific attribute name/value, and then use that as the parent object to continue my search. I'd like to be able to do that in one line, using .attributes

$test = $oIE.Document.getElementsByTagName('div')
;ConsoleWrite ( $test.length & @CRLF )
For $node in $test
 If $node.Attributes("class").value = "welcome" Then
  $oCorrectNode = $node
 EndIf
Next
$oCorrectNode = $oCorrectNode.getElementsByTagName('span')
For $node in $oCorrectNode
 ConsoleWrite ( $node.innerHTML & @CRLF )
Next

In the end, I would prefer something like this, if possible:

$node = $oIE.document.getElementsByTagName('div').attributes('[class=welcome]').getElementsByTagName('span')

currently, i can do this to drill down by only elements:

$node = $oIE.document.getElementsByTagName('div').item().getElementsByTagName('span').item(0)

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...