Possible Duplicate:
Select xml node by attribute in php
Is there any function like getElementByAttribute
in PHP? If no, how do I create a workaround?
E.g.
<div class="foo">FOO!</div>
How do I match that element?
Possible Duplicate:
Select xml node by attribute in php
Is there any function like getElementByAttribute
in PHP? If no, how do I create a workaround?
E.g.
<div class="foo">FOO!</div>
How do I match that element?
You can use XPath:
$xpath = new DOMXPath($document);
$results = $xpath->query("//*[@class='foo']");