问题
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>
回答1:
Are you wanting to get the name of the root node?
$xml = simplexml_load_string($str);
echo $xml->getName();
来源:https://stackoverflow.com/questions/2811797/get-root-node-of-xml-doc-using-simplexml