本文介绍了使用simplexml获取XML文档的根节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用simplexml_load_string()从以下XML中获取"ForgotPassword"?
Using simplexml_load_string() how do I get "ForgotPassword" from the following XML?
<?xml version="1.0" encoding="utf-8"?>
<ForgotPassword>
<version>1.0</version>
<authentication>
<login>username</login>
<apikey>login</apikey>
</authentication>
<parameters>
<emailAddress>joesmith@example.com</emailAddress>
</parameters>
</ForgotPassword>
推荐答案
是否要获取根节点的名称?
Are you wanting to get the name of the root node?
$xml = simplexml_load_string($str);
echo $xml->getName();
这篇关于使用simplexml获取XML文档的根节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!