title: Remove whitespaces and line breaks from captured data with Php Dom Document
body: <p>I'm trying to capture home_impact and away_impact but when i extract the text its full of blank lineas, white spaces, break lines and such like this:</p>
  
  <pre><code>  David Luiz 
          35'
  
  
  
  
  
  
          36'
  
              De Gea
  </code></pre>
  
  <p>I've also tried by extract just the div id match_info but it generates just an array with one element and also it has a lot of line breaks. I've tried using preserveWhiteSpace and preg_replace but didn't work, any idea how to avoid that? Thanks.</p>
  
  <p>Html:</p>
  
  <pre><code>   &lt;div id="match_info"&gt;
                             &lt;div class="direct_line"&gt;
              &lt;div class="home_impact"&gt;&lt;div class='player_name'&gt;David Luiz &lt;/div&gt;&lt;/div&gt;
                  &lt;div class="minute"&gt;35'&lt;/div&gt;
                  &lt;div class="away_impact"&gt;
                  &lt;/div&gt;
          &lt;/div&gt; 
                 &lt;div class="direct_line"&gt;
              &lt;div class="home_impact"&gt;&lt;/div&gt;
                  &lt;div class="minute"&gt;36'&lt;/div&gt;
                  &lt;div class="away_impact"&gt;
                      &lt;div class='player_name'&gt;De Gea&lt;/div&gt;
                  &lt;/div&gt;
          &lt;/div&gt; 
                  &lt;div class="direct_line"&gt;
              &lt;div class="home_impact"&gt;&lt;/div&gt;
                  &lt;div class="minute"&gt;38'&lt;/div&gt;
                  &lt;div class="away_impact"&gt;
                      &lt;div class='player_name'&gt;Ashley Cole&lt;/div&gt;
                  &lt;/div&gt;
                 &lt;div class="home_impact"&gt;&lt;div class='player_name'&gt;Juan Mata&lt;/div&gt;/div&gt;
                  &lt;div class="minute"&gt;35'&lt;/div&gt;
                  &lt;div class="away_impact"&gt;
                  &lt;/div&gt;
          &lt;/div&gt; 
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>$html = file_get_contents($url);
  $doc = new DOMDocument();
  //$doc-&gt;preserveWhiteSpace = FALSE;
  @$doc-&gt;loadHTML($html);
  $xpath = new DOMXpath ($doc);
  $expresionHome="//div[@class='home_impact']";
  $expresionAway="//div[@class='away_impact']";
  $nodesHome = $xpath-&gt;evaluate($expresionHome);
  $nodesAway = $xpath-&gt;evaluate($expresionAway);
  for ($i=0;$i&lt;$nodesHome-&gt;length;$i++)
  {
  echo $nodesHome-&gt;item($i)-&gt;nodeValue;
  echo $nodesAway-&gt;item($i)-&gt;nodeValue;
  }
  </code></pre>