I have the following XML file called 'cookie_domain.xml' with the contents:
<?xml version="1.0" encoding="UTF-8"?>
<setting>
<parameter>cookie_domain</parameter>
<displayname>Cookie Domain</displayname>
<grouping>Sessions</grouping>
<selecttype>text</selecttype>
<setting />
<help>Domain that the cookie is valid for</help>
</setting>
which I load into an object using:
$xml_object = simplexml_load_file('cookie_domain.xml');
The problem is that I want the 'setting' element to be null as specified in the XML, but what I get from the object, when I turn it into an array, is:
Array
(
[parameter] => cookie_domain
[displayname] => Cookie Domain
[grouping] => Sessions
[selecttype] => text
[setting] => SimpleXMLElement Object
(
)
[help] => Domain that the cookie is valid for
)
Is there anyway to get SimpleXML to honour the 'null' value instead of putting a 'SimpleXMLElement Object' in there? So I would end up with:
Array
(
[parameter] => cookie_domain
[displayname] => Cookie Domain
[grouping] => Sessions
[selecttype] => text
[setting] =>
[help] => Domain that the cookie is valid for
)
I am using this information to import into a database and the Object is causing issues as I need the element to be there, even if it is 'null' as this is valid in my application.
Thanks very much,
Russell