[ create a new paste ] login | about

Link: http://codepad.org/8AL91w0y    [ raw code | output | fork ]

PHP, pasted on Jun 16:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$document = new DOMDocument();
$html = <<<END
<html>
<div class="foo">
<span id="hello">Hello!</span>
</div>
<div>
    <div class="foo"></div>
</div>
</html>
END;
$document->loadHTML($html);

$xpath = new DOMXPath($document);
$results = $xpath->query("//*[@class='foo']");

foreach($results as $node) {
    var_dump($node);
}
?>


Output:
1
2
3
4
object(DOMElement)#3 (0) {
}
object(DOMElement)#4 (0) {
}


Create a new paste based on this one


Comments: