eli orellana - 2012-01-16 09:49:53
I have been playing around with this Class and was wondering why you chose the specific array key value pair arrangement that you did.
I can understand that your method has arranged the array to have as much information as possible and accessible if you knew the information. But for simpler xml files a simple structure like this would be perfect
$xmlArr = array('root' => array(
'child' => array(
'name' =>'some name',
'value' => 'some value'
)
);
that way it can be accessed using
echo $xmlArr['root'][0]['name'];
echo $xmlArr['root'][0]['value'];
My XML document has a simple structure like this, and is why I was wondering why so much complexity with the array $parser->structure
<settings>
<title>Database Settings</title>
<setting>
<name>Host</name>
<value>localhost</value>
</setting>
</settings>
which would ideally be accessed with
echo $xmlArr['settings']['title'];
echo $xmlArr['settings'][0]['name'];
echo $xmlArr['settings'][0]['value'];
Also, out of curiosity. Do you have benchmarks on the benefits of caching the XML files rather than keep reading and extrating the data?
Thank you for contributing this Class, it has been extremely helpful and also further helped me learn PHP. I made some changes to the formatting and to the functions to tweak the output to my needs.
As a request can you update the example page that executes the Dump functions to also show methods used to access the array data from example.xml through $parser->structure