title: how to create xml files via php and MySQL
body: <p>I have a problem in XML files.
  I searched through the internet and found lots of examples for my problem but I am not an expert on XML files and couldn't solve my problem. I want  to do and XML file and work like RSS FEED. So, I am taking my data from my database and try to create the xml-code. Here what I have in my php file
  (and it is not validated because of this problem: Undefined root element: channel)</p>
  
  <pre><code>&lt;?php
  include "connection.php";
  //create the table with the fields
    $rss_table = array(); 
    $query = mysql_query("SELECT * FROM rssfeeds");
      while($values_query = mysql_fetch_assoc($query))
      {
          $rss_table [] = array(
          'title' =&gt; $values_query['title'],
          'description' =&gt; $values_query['summary'],
          'link' =&gt; $values_query['link']
          );
      }
  
  $doc = new DOMDocument(); 
  $doc-&gt;formatOutput = true;
  $doc-&gt;encoding = "utf-8";
  
  $r = $doc-&gt;createElement( "channel" ); 
  $doc-&gt;appendChild( $r ); 
  
     //$i=0;
      foreach( $rss_table as $rss ) 
      { 
      $b = $doc-&gt;createElement( "item" );
          $title = $doc-&gt;createElement( "title" ); 
          $title-&gt;appendChild( 
          $doc-&gt;createTextNode( $rss['title'] ) 
          ); 
      $b-&gt;appendChild( $title ); 
  
  
      $description = $doc-&gt;createElement( "description" ); 
      $description-&gt;appendChild( 
      $doc-&gt;createTextNode( $rss['description'] ) 
      ); 
      $b-&gt;appendChild( $description );
  
      $link = $doc-&gt;createElement( "link" ); 
      $link-&gt;appendChild( 
      $doc-&gt;createTextNode( $rss['link'] ) 
      ); 
      $b-&gt;appendChild( $link );
  
      $r-&gt;appendChild( $b );
      }
  echo $doc-&gt;saveXML();
  $doc-&gt;save("rssfeeds.xml") 
  ?&gt;
  </code></pre>
  
  <p>I want to have title - link - description 
  Simple one... nothing more</p>
  
  <p>And here is what I get in rssfeeds.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;channel&gt;
    &lt;item&gt;
      &lt;title&gt;winter week&lt;/title&gt;
      &lt;description&gt;You can come as you are! &lt;/description&gt;
      &lt;link&gt;http://tdm2000international.org/tdm2000international/news.php&lt;/link&gt;
    &lt;/item&gt;
    &lt;item&gt;
      &lt;title&gt;Greek night&lt;/title&gt;
      &lt;description&gt;elliniki bradua sto magazi&lt;/description&gt;
      &lt;link&gt;http://tdm2000international.org/tdm2000international/news.php&lt;/link&gt;
    &lt;/item&gt;
    &lt;item&gt;
      &lt;title&gt;event website&lt;/title&gt;
      &lt;description&gt;first of december, how is it going?&lt;/description&gt;
      &lt;link&gt;http://tdm2000international.org/tdm2000international/news.php&lt;/link&gt;
    &lt;/item&gt;
  &lt;/channel&gt;
  </code></pre>
  
  <p>Nice format, but it has problem. I do not understand where the problem is.
  Any help would be appreciated</p>
  
  <p>(I also check this website for any solution, but I could not found my solution..So, sorry about this post, if it is already exist)</p>