title: convert txt to sitemap.xml with PHP
body: <p>Supposed that I have text database include is:</p>
  
  <pre><code>http://example.com,monthly,0.3
  http://example.com/one,daily,0.5
  http://example.com/two,weekly,0,8
  </code></pre>
  
  <p>I would like to convert to my text database to sitemap.xml.</p>
  
  <pre><code>$fp = fopen('./database.txt', 'r');
  $xml = new XMLWriter;
  $xml-&gt;openURI('./sitemap.xml');
  $xml-&gt;setIndent(true); 
  $xml-&gt;startElement('urlset');
  while ($line = fgetcsv($fp)) {
     if (count($line) &lt; 4) continue;
     $xml-&gt;startElement('url');
     $xml-&gt;writeElement('loc', $line[0]);
     $xml-&gt;writeElement('changefreq', $line[1]);
     $xml-&gt;writeElement('priority', $line[2]);
  echo $xliff-&gt;getDocument();
     $xml-&gt;endElement();
  }
  $xml-&gt;endElement();
  </code></pre>
  
  <p>I tried this code, I couldn't add this part...</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;urlset 
    xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' 
    xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'     
    xsi:schemaLocation='http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"&gt;
  </code></pre>