title: PHP retrieve xml node value with simplexml
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1937056/php-simplexml-get-innerxml">PHP SimpleXML get innerXML</a>  </p>
  </blockquote>
  
  
  
  <p>I've seen others questions related to simplexml and node value but couldn't find an answer to my problem.</p>
  
  <p>I have a PHP var which contains an xml document formed like that :</p>
  
  <pre><code>&lt;div id="container"&gt;
  &lt;div id="header"&gt;&lt;/div&gt;
  &lt;div id="main"&gt;
        ##CONTENTS## cd &lt;strong&gt;dscsdcsd&lt;/strong&gt; sdcsc
    &lt;div&gt;my content here&lt;/div&gt;
    &lt;span&gt;and there&lt;/span&gt;
      &lt;/div&gt;
  &lt;div id="footer"&gt; &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to retrieve the <em></em> node <strong>value</strong>. But with the following code, I also retrieve the  tag :</p>
  
  <pre><code>$xml = simplexml_load_string($_POST['newsletter_body']);
  $att = 'id';
  
    foreach ($xml-&gt;children() as $el) {
      if($el-&gt;attributes()-&gt;$att == 'main') {
        $body_content = $el-&gt;asXml();
      }
    }
  </code></pre>
  
  <p>Could someone tell me how to get only <strong>node value</strong> (without using xpath)? </p>
  
  <p>To be clear, now I get :</p>
  
  <pre><code>&lt;div id="main"&gt;
        ##CONTENTS## cd &lt;strong&gt;dscsdcsd&lt;/strong&gt; sdcsc
        &lt;div&gt;my content here&lt;/div&gt;
        &lt;span&gt;and there&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And I just want :</p>
  
  <pre><code>      ##CONTENTS## cd &lt;strong&gt;dscsdcsd&lt;/strong&gt; sdcsc
        &lt;div&gt;my content here&lt;/div&gt;
        &lt;span&gt;and there&lt;/span&gt;
  </code></pre>
  
  <p>Many thanks</p>