how to get website content with xpath? -
i want check if website uses schema.org tags. script empty result.
$surl = 'http://adresse.gelbeseiten.de/120002540061/alois-dallmayr-kg/muenchen/altstadt#gaststaetten-und-restaurants;originindex=1;origin=/restaurant/muenchen'; $dom = new domdocument(); @$dom->loadhtmlfile($surl); $xpath = new domxpath($dom); $alinks = array(); $vres = $xpath->query('//text()[contains(.,"itemprop="streetadress")]'); foreach ($vres $obj) { $alinks[] = $obj->textcontent; } print_r($alinks);
not sure want exactly.
if going <span id="inserat_addr_str" itemprop="street-address"> dienerstr. 14-15</span>
using itemprop
attribute, try use following xpath (id , text element, assume want use itemprop
)
$vres = $xpath->query("//*[@itemprop='street-address']"); // $vres = $xpath->query("//*[@id='inserat_addr_str']"); // $vres = $xpath->query("//*[contains(text(), 'dienerstr. 14-15')]");
Comments
Post a Comment