title: ampersand in simple xml document with DOMDocument
body: <p>Well here is the deal, i'm recovering data from my web page database and creating an xml with the only purpose of importing that data to my local database. i do this because the data in my local DB is pretty specific and i don't want to fill it  with useless information, so what i do is this:</p>
  
  <pre><code>&lt;?php
  ini_set( 'default_charset', 'UTF-8' );
  
  $ID = $_GET['ID'];
  
  $personInfo = GetPersonSoftwareByID($ID); //this is a function that i created on my own
  
  //xml section
  
  $domTree = new DOMDocument('1.0', 'UTF-8');
  $rootXML = $domTree-&gt;createElement( 'XML' );
  $rootXML = $domTree-&gt;appendChild($rootXML);
  
  $personalSoftware = $domTree-&gt;createElement( 'PERSON_SOFTWARE' );
  $personalSoftware = $rootXML-&gt;appendChild($personalSoftware);
  
  $soft = $domTree-&gt;createElement('SOFTWARE');
  $level = $domTree-&gt;createElement('LEVEL');
  
  $soft-&gt;nodeValue = $softwares[software];// here the value is = 'Plant&amp;ID'
  $level-&gt;nodeValue = $softwares[level];
  
  $soft = $personalSoftware -&gt;appendChild($soft);
  $level = $personalSoftware -&gt;appendChild($level);
  
  header('Content-type: text/xml; charset=UTF-8');
  header('Content-Disposition: attachment; filename="test.xml");
  
  echo $domTree-&gt;saveXML();
  ?&gt;
  </code></pre>
  
  <p>but when i try to create the xml this comes out:
      Warning: main() [function.main]: unterminated entity reference ID in line xx</p>
  
  <p>i've tried with htmlentities and the xml is created but when  i try to import with simplexml_load_string i get a whole bunch of alerts but not with &amp; rather with other characters such as &Atilde; and &sup3;</p>
  
  <p>is there a way to fix or saving in the xml as is in the DB?  by the way the data stored in the web page DB and local DB are information in spanish</p>
  
  <p>THANKS IN ADVANCE!</p>