【问题标题】:Unable to access html content from xml无法从 xml 访问 html 内容
【发布时间】:2014-01-07 10:02:01
【问题描述】:

我正在将 XML 字符串转换为 SimpleXMLElement 对象并访问该对象的键和元素。在这个过程中,我面临一个问题,即 xml 中的锚标记无法被对象访问。

$resultobject = simplexml_load_string($xml,null,LIBXML_NOCDATA);

$resultobject 显示为:

[channel] => SimpleXMLElement Object
    (
     [item] => Array
      (
       [0] => 
         SimpleXMLElement Object
          (
           [title] => "Crises and deadlocks when they occur" - www.google.com
          )
      )
    )

但是当试图访问 title

echo $resultobject->channel->item[0]->title;

获取结果:

“危机和死锁发生时”-

链接 www.google.com 或每个条目中缺少的任何链接。这里有什么问题?

【问题讨论】:

  • 你能发布你的XML吗?

标签: php xml parsing object xml-parsing


【解决方案1】:

试试这个:

echo htmlentities($resultobject->channel->item[0]->title);

【讨论】:

    猜你喜欢
    • 2016-01-10
    • 1970-01-01
    • 2020-06-05
    • 1970-01-01
    • 2020-04-12
    • 2013-04-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多