jdelaney Posted August 20, 2012 Posted August 20, 2012 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.
salvobellino95 Posted August 21, 2012 Posted August 21, 2012 (edited) $nodeobject.getAttribute('attribute').value ; for get attributes in you situation you can use $nodeobject.className, it returns the class attribute Edited August 21, 2012 by salvobellino95
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now