Home  >  Article  >  Backend Development  >  XML只能取到对象,获取不到节点数值

XML只能取到对象,获取不到节点数值

WBOY
WBOYOriginal
2016-06-23 13:17:311286browse

输入数据:$xml=SimpleXMLElement Object([URL] => http://test.net/index.php?m=home&c=index&a=test[ToUserName] => touser[FromUserName] => fromuser[CreateTime] => 20160129[MsgType] => text[Content] => test_message[MsgId] => 01)$t=$xml->FromUserName;print_r($t);结果是:SimpleXMLElement Object([0] => fromuser)取不到值。实在无解求帮助。


回复讨论(解决方案)

现在都用json了,别用xml

fromuser 不就是值吗?你还想要什么

fromuser 不就是值吗?你还想要什么


$t的值是SimpleXMLElement Object,不是fromuser

现在都用json了,别用xml


微信公众号的交互都是xml

fromuser 不就是值吗?你还想要什么


麻烦请教一下,如果我想要得到fromuser这个值,该如何操作?

你要取什么值?

你要取什么值?


取字符串类型fromuser

print_r($t[0]); 这样试试

print_r($t[0]); 这样试试


取到值了!非常感谢!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn