PHP の DomDocument クラスを使用して HTML を解析しています。
アンカーを持つhtmlを指定し、すべてのアンカーを見つけて配列に格納するように依頼すると、アンカーがないかのように空の配列が返されます。
なぜこれを行うのですか?どうすれば修正できますか?
コードは次のとおりです。
$dom = new DOMDocument();
$domObject->loadHTML($content);
$anchors = $domObject->getElementsByTagName('a');
print_r($anchors); // returns empty array.
$content は次のようになります。
<p>
Friend David, I do not think we shall need a call bell as Hello! can be heard 10 to 20 feet away. What you think? Edison - P.S. first cost of sender & receiver to manufacture is only $7.00.[12] Hello, hello! New York, hello!
</p>
<a href="http://the-irf.com/hello/hello5.html">Prev</a>
<a href="hello7.html">Next</a>
<a href="end.html">End</a>
</body>
</html>