title: Accessing a nested node in an XML load by SimpleXMLElement
body: <p>I have an XML file with this structure.</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
      &lt;COMMUNITIES&gt;
      &lt;COMMUNITY ID="c001"&gt;
        &lt;NAME&gt;Town Services&lt;/NAME&gt; 
        &lt;TOP&gt;50&lt;/TOP&gt; 
        &lt;LEFT&gt;50&lt;/LEFT&gt; 
        &lt;WIDTH&gt;200&lt;/WIDTH&gt; 
        &lt;HEIGHT&gt;300&lt;/HEIGHT&gt; 
        &lt;URLS&gt;
            &lt;URL ID="U001"&gt;
                &lt;NAME&gt;Google.com&lt;/NAME&gt;
                &lt;URL&gt;http://www.google.com&lt;/URL&gt;
            &lt;/URL&gt;
            &lt;URL ID="U002"&gt;
                &lt;NAME&gt;Bing.com&lt;/NAME&gt;
                &lt;URL&gt;http://www.bing.com&lt;/URL&gt;
            &lt;/URL&gt;
            &lt;URL ID="U003"&gt;
                &lt;NAME&gt;Yahoo.com&lt;/NAME&gt;
                &lt;URL&gt;http://www.yahoo.com&lt;/URL&gt;
            &lt;/URL&gt;
            &lt;URL ID="U004"&gt;
                &lt;NAME&gt;Aol.com&lt;/NAME&gt;
                &lt;URL&gt;http://www.aol.com&lt;/URL&gt;
            &lt;/URL&gt;
        &lt;/URLS&gt; 
        &lt;/COMMUNITY&gt;
  &lt;/COMMUNITIES&gt;
  </code></pre>
  
  <p>I am able to get to the first-level elements NAME through HEIGHT with this script.</p>
  
  <pre><code>&lt;?php
  
  function get_nodes() {
  // load SimpleXML
  $nodes = new SimpleXMLElement('communities.xml', null, true);
  
  foreach($nodes as $node) // loop through 
  {
  
          echo "&lt;div id = '".$node['ID']."' class= 'comdiv ui-widget-content' style = 'top: ".$node-&gt;TOP."px; left: ".$node-&gt;LEFT."px; width: ".$node-&gt;WIDTH."px; height: ".$node-&gt;HEIGHT."px;'&gt; \n";
  
          echo "   &lt;p class = 'comhdr editableText ui-widget-header'&gt;".$node-&gt;NAME."&lt;/p&gt;\n";
  
          echo "   &lt;a href='#' onClick=\"delete_div('".$node['ID']."');\"&gt;Delete&lt;/a&gt;&amp;nbsp;&amp;nbsp;\n";
          echo "   &lt;a href='#' onClick=\"add_url('".$node['ID']."');\"&gt;Add URL&lt;/a&gt;&amp;nbsp;&amp;nbsp;\n";
  
          echo "&lt;/div&gt; \n";
  
          echo "&lt;script type='text/javascript'&gt;\n";
          echo "  $('#".$node['ID']."').resizable();\n";
          echo "  $('#".$node['ID']."').draggable();\n";
          echo "  $('#".$node['ID']."').draggable('option', 'handle', '.comhdr');\n";
          echo "&lt;/script&gt;\n";
  
  
          $nodeid = $node['ID'];
  
          $xurls = $node-&gt;URL; // WHAT IS THE WAY TO GET TO &lt;URLS&gt; and LOOP THOUGH ALL &lt;URL&gt; NODES
          $nurls = sizeof($xurls);
  
  }
          echo "&lt;script type='text/javascript'&gt;\n";
          echo "  $('.editableText').editableText();\n";
          echo "&lt;/script&gt;\n";
  
     return;
  }
  
  echo get_nodes();
  ?&gt;
  </code></pre>
  
  <p>How do I get an array of the  nodes contained in the  node?  Once I get that array, I must retrieve the NAME and URLC for each URL.</p>
  
  <p>Thanks.</p>