【问题标题】:get the value of simplexmlelement object php获取simplexmlelement对象php的值
【发布时间】:2011-09-29 23:21:17
【问题描述】:

我尝试了太多东西来从下面的代码中读取 [label] 的值:

    Array ( [0] => 
    SimpleXMLElement Object
    (
       [id] => x 
       [published] => 2011
       [category] =>
     Array ( [0] => 
      SimpleXMLElement Object 
      ( 
      [@attributes] => 
        Array (
        [scheme] => y 
        [term] => t 
        ) )
        [1] => SimpleXMLElement Object 
        ( [@attributes] => 
        Array (
        [scheme] => y2 
        [term] => Film
        [label] => Film & Animation 
        ) )

它以数字数组开头。

【问题讨论】:

标签: php simplexml


【解决方案1】:

你的答案是不是很简单:

$data->category['label']?

下次见simplexml文档,所有属性都可以从数组中访问,所有子节点都可以通过对象属性操作符访问。

如果您有很多类别,那么您将在“category[0]”处有一个数组

【讨论】:

  • 哦等等,我没看清楚结构,其实是:$data->category[1]['label']
猜你喜欢
  • 2011-02-21
  • 1970-01-01
  • 2015-11-28
  • 1970-01-01
  • 2020-01-04
  • 2011-02-14
  • 2013-12-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多