title: Get the width and height of each element's attribute via DOM or XPATH
body: <p>How can I get the width and height of each element's attribute?</p>
  
  <p>For instance,</p>
  
  <pre><code>$dom = new DOMDocument;
  $dom-&gt;loadHTML('&lt;div class="item" style="width:295px; height:210px; border:1px solid #000;"&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;');
  
  foreach( $dom-&gt;getElementsByTagName('div') as $node ) 
  {
      $style = $node-&gt;getAttribute( 'style' );
  
      var_dump($style);
  }
  </code></pre>
  
  <p>result,</p>
  
  <pre><code>string 'width:295px; height:210px; border:1px solid #000;' (length=49)
  string '' (length=0)
  </code></pre>
  
  <p>but these are what I am after,</p>
  
  <ol>
  <li>select the <code>div</code> that has the classname of <code>item</code> only.</li>
  <li>get <code>295</code> (width) and <code>210</code> (height) only.</li>
  </ol>
  
  <p>Is it possible with DOM? Or XPATH?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I seem to manage to select the div with the classname now,</p>
  
  <pre><code>$dom = new DOMDocument;
  $dom-&gt;loadHTML('&lt;div class="item" style="width:295px; height:210px; border:1px solid #000;"&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;');
  
  $xpath = new DOMXpath($dom); 
  
  foreach ($xpath-&gt;query('//*[@class="item"]') as $node) {
  
      $style = $node-&gt;getAttribute( 'style' );
  
      var_dump($style);
  }
  </code></pre>
  
  <p>Now this is what I am after only,</p>
  
  <p>get <code>295</code> (width) and <code>210</code> (height).</p>