||1. instead of index value why not associative value for $structure
|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
My XML document has a simple structure like this, and is why I was wondering why so much complexity with the array $parser->structure
which would ideally be accessed with
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
||2. Re: instead of index value why not associative value for $struct
|2012-01-22 02:45:59 - In reply to message 1 from eli orellana|
|Well, this approach was chosen because you can have a single index for all XML elements. There is no need for nested array structures.|
You can obtain the index of an element by joining the path of the parent element a comma and the number of the child element among all elements of the parent. So the index of the root element is always "0" and the first child element is "0,0" and so on.
As for caching, I did not do any benchmarks but it is a matter of common sense to expect that parsing XML files is always slower than loading a cache file and unserialize it.