سؤال

I'm not finding a way to retrieve all elements that have an attribute ec:edit. I've only found examples getting namespaced elements, but not attributes.

And there is also no result when searching the attributes with attr() or hasAttr().

dbpedia example:

foreach ($qp->branch()->find('foaf|page') as $img) {
   print $img->attr('rdf:resource') . PHP_EOL;
} 

rdf file sample:

<dbpprop:artist rdf:resource="http://dbpedia.org/resource/The_Beatles" />

But this won't retrieve any results:

$edits = $htmldocument->find('div[mc|edit];
foreach ($edits as $key => $value) {
    echo $value->attr('mc:edit');
}

sample data:

<div mc:edit="stuff"> // etc

I get nothing.

هل كانت مفيدة؟

المحلول

Ok, lambdas solve everything:

find('div')->filterLambda('return qp($item)->hasAttr("mc:edit");');
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top