Skip to content

_HTMLParser_GetElementsByTagName Function

Anders Pedersen edited this page Jan 8, 2018 · 4 revisions

Syntax

Array<TokenListToken*> _HTMLParser_GetElementsByTagName(
    STRING  $sTagName,
    POINTER $pItem,
    STRING  $sHTML
)

Description

Returns found start tags with tag names matching $sTagName within $pItem

Parameters

Name Description Type
$sTagName Tag name string String
$pItem TokenListToken structure pointer Pointer
$sHTML The HTML String

Remarks

$sTagName is case-insensitive

Example

;_HTMLParser_GetElementsByTagName 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>
Clone this wiki locally