Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get root node of XML doc using simplexml

Tags:

php

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>[email protected]</emailAddress>
    </parameters>
</ForgotPassword>
like image 299
John Conde Avatar asked May 11 '10 15:05

John Conde


1 Answers

Are you wanting to get the name of the root node?

$xml = simplexml_load_string($str);
echo $xml->getName();
like image 84
Mark Avatar answered Oct 20 '22 13:10

Mark