简体   繁体   中英

Get root node of XML doc using simplexml

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM