Skip to content

Instantly share code, notes, and snippets.

@slav123
Last active August 29, 2015 14:02
Show Gist options
  • Save slav123/481e9022e04054c7f230 to your computer and use it in GitHub Desktop.
Save slav123/481e9022e04054c7f230 to your computer and use it in GitHub Desktop.
parse doom against class
<?php
$dom = new DOMDocument;
libxml_use_internal_errors(true);
if (!$dom->loadHTML($data)) {
echo 'failed to load DOM';
}
$xpath = new DOMXPath($dom);
$entries = $xpath->query('//*[contains(concat(" ", normalize-space(@class), " "), " resultBody ")]/@id');
$return = array();
foreach ($entries as $entry) {
$return[] = substr($entry->nodeValue, 1);
}
return $return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment