Example Domain
$link = new DOMDocument(); $link->loadHTML('Example Domain'); $href = $link->getElementsByTagName('a')->item(0)->getAttribute('href'); echo $href;
Everyday Italian Giada De Laurentiis
$bookstore = new DOMDocument(); $bookstore->loadXML('This will output: 10.00 Package library: The PHP DOMElement getAttribute() method is part of the PHP DOM extension, which is built-in and does not require any additional packages or libraries.'); $price = $bookstore->getElementsByTagName('book')->item(0)->getAttribute('price'); echo $price; Everyday Italian Giada De Laurentiis