PHP var_dump of XML from simplexml_load_string



I have an XML object created by simplexml_load_string from the following XML:



<?xml version="1.0" encoding="UTF-8"?>
<Website hasRead="true" hasWrite="true" key="managementui" terminalUserPin="" username="admin">
<Section key="organisation">
<Controller key="Sites">
<Function hasRead="false" hasWrite="false" key="estateLayout"/>
</Controller>
</Section>
<Section hasRead="false" hasWrite="false" key="settings"/>
</Website>


The is stored in variable $xml


When I try:



$xmlkey = $xml['key'];
var_dump($xmlkey);


I expect to see the string 'managementui' but instead I get an exception. The error log isn't even showing anything. What's going on here?


Just trying to learn PHP after years of Java experience. When people say PHP is 'easy' it must be some strange usage of the word 'easy' I wasn't previously aware of :)


No comments:

Post a Comment