$html = new DOMDocument();
@$html->loadHtmlFile($url);
$xpath = new DOMXPath( $html );
//Query to pull all reviews on the page
$q="//div[starts-with(@id,empReview_)]/h3/meta[1]/@content";
$nodelist = $xpath->query($q);
foreach ($nodelist as $n){
echo $n->nodeValue;
echo"<br><br>";
}
我正在尝试在以下 XML 上运行的查询:
<div id="empReview_2055942" class="employerReview" itemscope="" itemtype="http://schema.org/Review">
<h2 class="summary">
<h3 class="review-microdata-heading">
<span class="gdRatingStars"> </span>
Former
<span itemprop="author">IT Engineer Intern in Santa Clarita, CA</span>
<meta content="4" itemprop="reviewRating"/>
使用 Firepath 时它直接进入元素,但没有通过我在 php.ini 中的查询回显该值。
任何帮助将不胜感激。