title: Passing PHP variables to XML in a .php file
body: <pre><code>&lt;?php
  
  include "../music/php/logic/core.php";
  include "../music/php/logic/settings.php";
  include "../music/php/logic/music.php";
  $top = "At world's end";
  
  
  // create doctype
  $dom = new DOMDocument("1.0");
  
  header("Content-Type: text/xml");
  
  ?&gt;
  
  &lt;music&gt;
  &lt;?php $_xml = "&lt;title&gt;".$top."&lt;/title&gt;";
  echo $_xml; ?&gt;
  &lt;/music&gt;
  </code></pre>
  
  <p>I'm using this code to generate a dynamic XML document. The file is saved as PHP.
  My problem is that I can't echo php variables into the xml. However I can echo "literal" type text. I can't see anything wrong with my approach, it just doesn't work!</p>
  
  <p>I'm pretty new to XML so I've probably missed something glaringly simple.</p>
  
  <p>I've also tried lines like:</p>
  
  <pre><code>&lt;title&gt;&lt;?php echo $top; ?&gt;&lt;/title&gt;
  </code></pre>