title: Using DOM PHP Parse child contents
body: <pre><code>&lt;h2&gt;
  &lt;strong&gt;
  &lt;a href="http://www.linkedin.com/pub/rom-agustin/0/111/947" title="Rom Agustin"&gt;
    &lt;span class="given-name"&gt;Rom&lt;/span&gt;
    &lt;span class="family-name"&gt;Agustin&lt;/span&gt;
  &lt;/a&gt;
  &lt;/strong&gt;
  &lt;/h2&gt;
  </code></pre>
  
  <p>So i need to parse the two span classes and store them each in a variable.</p>
  
  <p>span.given-name = $given_name</p>
  
  <p>span.family-name = $family_name</p>
  
  <p>Right now my code is :</p>
  
  <pre><code>foreach($vcard as $items):
      $names = $items-&gt;getElementsByTagName('h2');
      $name = $names-&gt;item(0)-&gt;nodeValue;
      echo $name; //Rom Agustin
  endforeach;
  </code></pre>
  
  <p>How to properly separated those two? or how can i just target the class? I've read the DOM in php.net but there is no GetElementbyClass. Tried explode, very messy.</p>