我对抓取XML文档不太了解。可能是一个小错误。
Feed网址:http://www.simplifyingthemarket.com/feed/
代码: -
$url = 'http://www.simplifyingthemarket.com/feed/';
$XmlObject = new SimpleXmlElement( file_get_contents($url) );
print_r($XmlObject->channel[0]->item[0]->description[0]);
输出: -
SimpleXMLElement Object ( )
必需输出: -
<a href="http://www.simplifyingthemarket.com/wp-content/uploads/2015/04/Where-Should-I-Retire.jpg"><img class="alignnone wp-image-30608" src="http://www.simplifyingthemarket.com/wp-content/uploads/2015/04/Where-Should-I-Retire.jpg" alt="Where Should I Retire [INFOGRAPHIC] | Simplifying The Market" width="600" height="1035" /></a>
<h4>Some Highlights From The Report:</h4>
<ul>
<li>80% of all pre-retirees in the South Atlantic region plan to stay there in retirement</li>
<li>4 out of 10 pre-retirees plan to relocate in retirement</li>
<li>Retirees in the South Central Region are most satisfied with their Cost of Living</li>
<li>For more information or to read the full report: <a href="https://www.ml.com/articles/age-wave-survey.html">Click Here</a></li>
</ul>
注意:我的客户已购买了他们的Feed,因此没有法律问题。可以通过联系方式提供更多信息。
答案 0 :(得分:1)
要将节点的值作为字符串访问,首先必须将其转换为字符串。在你的情况下,它会像:
print_r((string) $XmlObject->channel[0]->item[0]->description[0]);