Get root node of XML doc using simplexml

末鹿安然 提交于 2019-12-28 03:06:02

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!