Reputation: 949
I'm trying to extract hrefs, srcs and value attributes from a HTML string using xpath
$dom = new DOMDocument;
libxml_use_internal_errors(true);
$dom->loadHTML (stripslashes ($content));
$xpath = new DOMXPath ($dom);
libxml_clear_errors();
$doc = $dom->getElementsByTagName('html')->item(0);
$srcs = $xpath->query('.//@src');
$hrefs = $xpath->query ('.//@href');
$values = $xpath->query ('.//@value');
How can I combine the xpath query expressions with OR ? This way I would have only have one array to traverse.
Upvotes: 2
Views: 145
Reputation: 8405
$stuff = $xpath->query('.//@src | //@href | //@value');
| (or pipe) is the operator you're looking for.
Upvotes: 2