Using Zend_Dom_Query, I would like to retrieve meta data out of an HTML string.
to retrieve links you can simply query like so:
$results = $dom->query('a'); //Where $dom is your html string
Unfortunately this doesn't seem to work with meta
$results = $dom->query('meta'); //doesn't work
How can I retrieve meta data and then filter by its 'property' attribute?
An example of what I'm looking for:
public function meta($dom)
{
$results = $dom->query('meta'); //This is not a correct query (does anyone have an alternative?)
$links = array();
foreach ($results as $index => $result) {
if ($result->getAttribute('property') == 'title') { //find <meta property="title"
echo $result->getAttribute('content') . '<br />'; //echo the content attribute of the title
}
}
return $results;
}
This code would work once the query is correct. However I would like to take it a step further and query directly for <meta property="title" content="This is the Title" />
instead of retrieving all meta and looping around to get the right one.
Any help with either getting all meta data using zend_dom_query or (more importantly) querying to receive only the meta data where property == title would be appreciated.
Thanks