获取 simplexmlelement 对象 php 的值
我尝试了太多的方法来从下面的代码中读取 [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
) )
它以数字数组开头。
I try too many thing to read the value of the [label] from the code below :
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
) )
it start with numeric array.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的答案是不是很简单:
下次看 simplexml 文档,所有属性都可以从数组访问,所有子节点都可以通过对象属性运算符访问。
如果您有很多类别,那么您将在“category[0]”处有一个数组
Isn't your answer as simple as:
See simplexml documentation next time, all attributes are accessible from an array, and all subnodes are accessible through the object property operator.
If you have many categories, then you will have an array at "category[0]"