title: PHP DOM getElementsbytagname() getElementById()
body: <p>I'm working in PHP and looking at the DOM to parse html and find certain information on the page.</p>
  
  <p>I have code working well using the <code>getElementsbyTagName()</code>:</p>
  
  <pre><code>foreach ($dom-&gt;getElementsByTagName('div') as $node) {
            $array_data[ ] = $node-&gt;nodeValue;
          }
  
  print_r($array_data);
  </code></pre>
  
  <p>On the page I'm looking at there are a lot of <code>&lt;div&gt;</code>'s.
  The div i'm interested in has a unique id on the page.
  I thought I could select this specific information By updating my code to look at the id as below:</p>
  
  <pre><code>foreach ($dom-&gt;getElementById('tree___34LHOENOP7') as $node) {
            $array_data[ ] = $node-&gt;nodeValue;
          }
  
  print_r($array_data);
  </code></pre>
  
  <p>This code does not seem to work.
  The html:</p>
  
  <pre><code>&lt;div id="tree___34LHOENOP7" style="margin-top: 5px; font-family: Verdana, Arial, sans-serif; height: 528px; overflow: auto;"&gt;
  &lt;ul&gt;&lt;li style="list-style-type:none;"&gt;&lt;span style="cursor:pointer;color:#D99F00;" onclick="prtv_C_E(this,'ExpandableRegionClickHandler','',2,true);(2,this);"&gt;UK&lt;/span&gt;&lt;img src="https://images... " title="re-centre map here" onclick="ExpandableRegionClickHandler(2,this);" style="display:inline;margin-left:7px;cursor:pointer;"&gt;&lt;ul style="display:block;"&gt;&lt;li style="list-style-type:none;"&gt;&lt;span style="cursor:pointer;color:#D99F00;" onclick="prtv_C_E(this,'ExpandableRegionClickHandler','',59,true);ExpandableRegionClickHandler(59,this);"&gt;Channel Islands&lt;/span&gt;&lt;img src="https://images... " title="re-centre map here" onclick="ExpandableRegionClickHandler(59,this);" style="display:none;margin-left:7px;cursor:pointer;"&gt;&lt;ul style="display:none;"&gt;&lt;li style="list-style-image:url('http://images…’);"&gt;&lt;a class="MapEventName" href="http://www... /guernsey" onclick="EventSpanClick(1439,this);" onmouseover="EventSpanMouseOver(1439,this);" onmouseout="EventSpanMouseOut(1439,this);"&gt;Guernsey&lt;/a&gt;&lt;/li&gt;
  </code></pre>