There really isn't much documentation on either of these, so I'm having a bit of trouble figuring out the best way to execute this. I have read Harry's introduction as well.

The problem:
I'm building an API to easily generate a javascript array using php. The structure for this menu is stored in an xml file allot like the following:

Code:
<?xml version="1.0" ?>
<menu>
    <item>
        <label>Home</label>
        <icon></icon>
        <link>index.php</link>
        <target>_blank</target>
        <desc>This is a desc</desc>
    </item>
     <item>
        <label>System</label>
        <icon></icon>
        <link>index.php</link>
        <target>_blank</target>
        <desc>This is a desc</desc>
    </item>
     <item>
        <label>Components</label>
        <icon></icon>
        <link>index.php</link>
        <target>_blank</target>
        <desc>This is a desc</desc>
        <item>
            <label>Articles</label>
            <icon></icon>
            <link>index.php</link>
            <target>_blank</target>
            <desc>This is a desc</desc>
            <item>
                <label>Add Article</label>
                <icon></icon>
                <link>Index.php</link>
                <target>Blank</target>
                <desc>test</desc>
              </item>
        </item>
    </item>
  </menu>
Each item can have nested items, and each nested item can have nested items...so on and so on. Something like:
Code:
Components
--------Articles
--------------Add Article
--------------Manage Articles
--------Downloads
System
Users
 ........
I'd like to be able to use the new features of the SPL, especially the RecursiveIteratorIterator and SimpleXMLIterator to generate javascript code such as:
Code:
var myMenu =
[
    [null, 'Home', 'url', 'target', 'description'],  
    [null, 'System', 'url', 'target', 'description'],
    [null, 'Components', 'url', 'target', 'description',
    [null, 'Articles', 'url', 'target', 'description',
        [null, 'Add Article', 'url', 'target', 'description']],
    [null, 'Downloads', 'url', 'target', 'description']
 ]
 ]
My question being, how can I manipulate each 'menu item block' individually? An example of "what doesn't work":
PHP Code:
 private function parseMenu()
     {
        
$sxe simplexml_load_file($this->file'SimpleXMLIterator');

        foreach(new 
RecursiveIteratorIterator($sxe1) as $item) {
           print  
$item->label "\r\n<br />";
        }
     } 
This prints the label of items and adds a br to every element, regardless if its a label or not.


Thanks in advance