PHPコードでxPathを使用してHTMLドキュメントをクエリするときに、DOMNodeListから読み取ろうとしている次のHTMLがあります。これは私のクエリ$description = $xpath->query("//div[@class='qsc-html-content']");
です。2番目のdiv内のすべてのものをフェッチできると期待しています。PHPのxPathは初めてです。問題は、私が次のようなことをしようとしたときです:
if(isset($description) && is_object($description)){
echo "DESCIPTION SET";
echo $description->tagName;
//echo $description->getElementsByTagName("p");
$productInfo['description'] = trim($description->nodeValue);
}
結果が出ません。
<div class="product-description ">
<div class="qsc-html-content">
<p><span class="Apple-style-span" style="background-color: #ffffff; font-family: Verdana, sans-serif;">Farida is a new and upcoming brand in the hookah market which specializes in solid brass hookahs. The designs are very unique and have not been seen in the hookah industry before. </span>This hookah stand about 36".</p>
<ul>
<li>Farida hose</li>
<li>Tongs, Grommets, Bowl, & Farida Gold Tray</li>
</ul>
<p><span style="color: #ff0000;"><strong><span style="font-size: x-small;">Please Not: </span></strong></span></p>
<p> Glass bases are mouth blown and sometimes have air bubbles as evidence of this fact. <span style="font-size: xx-small;">Artisans hand paint each glass base, making every one as unique as the artist. This results in a 100% unique finished product that may not look identical to the photo. It also means that sometimes the paint may have a slight smudge, a line may not be perfectly straight, or you may see the artist's brush strokes.</span></p>
<p>Egyptian products are handmade in a traditional manner. Because these hookahs are handmade, there are usually slight variations from hookah to hookah. Most hookahs contain visible weld lines or unpolished metal at the welds.</p>
<p> <span style="color: #ff0000;">FREE STARTER KIT INCLUDES:</span> 1 Holland Charcoal, 10 Mouth Tips, and 2 AL Fakher 50g Tobbacos Select Flavors</p>
<p><img alt="" height="55" src="media/round tablets.jpg" width="103" /> <img alt="" height="81" src="media/male_mouth_tips.jpg" width="109" /> <img alt="" height="86" src="media/d_al_fakher_50g.jpg" width="126" /> </p>
</div>
誰かが私が間違っているところを教えてくれます。xPathクエリでアンカータグのリストをフェッチしようとして、結果が単一のアンカーのみを返すという別の問題があります。
私はこの2時間、これに頭をぶつけていました。私は今疲れ果てています。
ありがとう