Addressing Attributes
Examples thus far have dealt with element nodes in particular. XPath also supports the selection of attribute nodes.
// Returns the id attribute nodes of all ul nodes
$list = $xpath->query('//ul/@id');
// Returns all ul nodes that have id attribute nodes
$list = $xpath->query('//ul/@id/..');
// Returns all id attribute nodes
$list = $xpath->query('//@id');
?>
© DOM Extension — Web Scraping >>> Back to TABLE OF CONTENTS <<< | |
| Views: 389 | |
| Total comments: 0 | |