脚本宝典收集整理的这篇文章主要介绍了使用simpleXML在php中解析远程xml,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<RSS> <channel> <ITem><title><![CDATA[bla]]></title><description><![CDATA[desc1]]></description><link>blah</link></item> <item><title><![CDATA[bleh]]></title><description><![CDATA[desc2]]></description><link>blahhh</link></item> </RSS> </channel>
我希望获得“描述”中的所有文本,但它被CDATA包围.我认为以下内容可行
$xMLurl = file_get_contents('http://anxmlfile.xml'); $xml = simplexml_load_string($xmlurl,null,LIBXML_NOCDATA); foreach ($xml->item as $item) { echo $item->description->innertext; }
我期待scrript回应“desc1desc2”,但是没有任何回声.
*更新
$xml = new SimpleXMLElement('http://www.skysports.COM/RSS/0,20514,11661,00.xml',LIBXML_NOCDATA,true); /* For each <character> node,we echo a separate <name>. */ foreach ($xml->item as $item) { echo (string)$item->description; }
以上是脚本宝典为你收集整理的使用simpleXML在php中解析远程xml全部内容,希望文章能够帮你解决使用simpleXML在php中解析远程xml所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。