title: Yii PHP Command Line App for extraction of Microdata values NOT working
body: <p>I want to extract Microdata values.</p>
  
  <p>I use a Yii App runned from the command line, using Putty.</p>
  
  <p>The following code does not generate any output;</p>
  
  <p>in $this->input->html i store an entire html document source;</p>
  
  <p>I think that somewhere at <code>$content = new DOMXPath($dom);</code> something cracks; dont know why</p>
  
  <p>If anyone knows, please give a hand;</p>
  
  <pre><code>$dom = new DOMDocument();
  
  $html = $this-&gt;input-&gt;html;
  
  $html = &lt;&lt;&lt;HTML
  echo $html;
  HTML;
  
          @$dom-&gt;loadHTML($html);
  
          echo $html;
  
          $content = new DOMXPath($dom);
  
          print_r($content);
  
          // find price
          try {
              echo '1'.$this-&gt;getMicrodataAttribute($content, 'http://data-vocabulary.org/Offer', 'price');
              $this-&gt;output-&gt;productPrice = $this-&gt;getMicrodataAttribute($content, 'http://data-vocabulary.org/Offer', 'price');
              //echo 'result output product price: '.$this-&gt;output-&gt;productPrice.PHP_EOL;
          } catch (Exception $e) {
  
          }
          // find title
          try {
  
              $this-&gt;output-&gt;productTitle = $this-&gt;getMicrodataAttribute($content, 'http://data-vocabulary.org/Product', 'name');
              if (!$this-&gt;output-&gt;productTitle)
                  if (preg_match("#&lt;title&gt;(.+)&lt;\/title&gt;#iU", $this-&gt;input-&gt;html, $t)) {
                      $this-&gt;output-&gt;productTitle = trim($t[1]);
                  }
          } catch (Exception $e) {
  
          }
  </code></pre>
  
  <p>and this is the function that should extract the microdata values:</p>
  
  <pre><code>public function getMicrodataAttribute($content, $itemtype, $itemprop) {
      $tags = $content-&gt;query("//*[@itemtype=\"$itemtype\"]//*[@itemprop=\"$itemprop\"]");
      //print_r($tags);
      if ($tags) {
          foreach ($tags as $tag) {
              //die('dd');
              if (!$tag-&gt;getAttribute('content')) {
                  return $tag-&gt;nodeValue;
              }
              return $tag-&gt;getAttribute('content');
          }
      }
      return null;
  }
  </code></pre>