-
Notifications
You must be signed in to change notification settings - Fork 2
_HTMLParser_Element_GetAttribute Function
Anders Pedersen edited this page Jan 5, 2018
·
1 revision
STRING _HTMLParser_Element_GetAttribute(
STRING $sAttributeName,
POINTER $pItem,
STRING $sHTML
)
Returns value of attribute from $pItem
Name | Description | Type |
---|---|---|
$sAttributeName | Attribute name string | String |
$pItem | TokenListToken structure pointer | Pointer |
$sHTML | The HTML | String |
$sAttributeName is case-insensitive
;_HTMLParser_Element_GetAttribute Function Demo
#include <HTMLParser.au3>
$sHTML = "<!DOCTYPE html><html><head><title>Demo page</title></head></head><body>Visit <a href="https://github.com/genius257/">genius257</a> on GitHub</body></html>"
$tTokenList = _HTMLParser($sHTML)
$pItem = _HTMLParser_GetFirstStartTag($tTokenList.First, $sHTML);finds first start tag. In this example it will be <html>
$aLinks = _HTMLParser_GetElementsByTagName("a", $pItem, $sHTML);finds all links <a>
For $i=0 To Ubound($aLinks, 1)-1
ConsoleWrite(_HTMLParser_Element_GetAttribute("href", $aLinks[$i], $sHTML)&@crlf)
Next