title: How to add an attribute to an XML Element in PHP without the xml header?
body: <p>I need to add a new attribute to xml elements stored in DB. This is not a complete XML, but just XML elements in the DB.</p>
  
  <p>When I do the following,</p>
  
  <pre><code>$node_xml = simplexml_load_string('&lt;node name="nodeA"&gt;this is a node&lt;/node&gt;');
  $node_xml-&gt;addAttribute('newattrib', "attribA");
  $res_xml = $node_xml-&gt;asXML();
  </code></pre>
  
  <p>I get <code>$res_xml</code> as:</p>
  
  <pre><code>"&lt;?xml version=\"1.0\"?&gt;\n&lt;node name=\"nodeA\" newattrib=\"attribA\"&gt;this is a node&lt;/node&gt;\n"
  </code></pre>
  
  <p>How do I eliminate the <code>&lt;?xml version=\"1.0\"?&gt;</code> part without doing a string manipulation?</p>