title: transforming XML (formerly KML) using XSLT
body: <p>Hi I'm trying to use the w3schools XSLT Tryit editor to transform a KML file (saved as an XML file), but I can't seem to get it working. Here is a snippet of my XML file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;kml xmlns="http://www.opengis.net/kml/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"&gt;
   &lt;Document&gt;
    &lt;name&gt;Bnsf RR cut&lt;/name&gt;
    &lt;open&gt;1&lt;/open&gt;
    &lt;Style&gt;
     &lt;ListStyle&gt;
      &lt;ItemIcon&gt;
       &lt;href&gt;kmzicon.png&lt;/href&gt;
      &lt;/ItemIcon&gt;
     &lt;/ListStyle&gt;
    &lt;/Style&gt;
    &lt;Folder&gt;
     &lt;name&gt;11/10/11 8:17:20 AM&lt;/name&gt;
     &lt;Placemark&gt;
      &lt;name&gt;Track&lt;/name&gt;
     &lt;/Placemark&gt;
    &lt;/Folder&gt;
    &lt;Placemark&gt;
     &lt;name&gt;Gray Mesa&lt;/name&gt;
     &lt;description&gt;&lt;![CDATA[&lt;img width="800" src="1.jpg"/&gt;]]&gt;&lt;/description&gt;
     &lt;Point&gt;
      &lt;coordinates&gt;-106.493097,34.446357,1692.000000&lt;/coordinates&gt;
     &lt;/Point&gt;
    &lt;/Placemark&gt;
   &lt;/Document&gt;
  &lt;/kml&gt;
  </code></pre>
  
  <p>And my XSLT:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;!-- Edited by XMLSpy® --&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
  &lt;xsl:template match="/"&gt;
        &lt;xsl:for-each select="Document/Placemark"&gt;
          &lt;xsl:value-of select="name"/&gt;
          &lt;xsl:value-of select="description"/&gt;
        &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>If I remove the kml tags in the XML code it works fine, but I would rather try and automate this and not have to delete code from numerous XMLs. I've tried adding "kml" to my XSLT code "/kml/Document/Placemark"> but that is not working. Thank you!</p>
  
  <p>What I would like my transformed XML to look like:</p>
  
  <pre><code> &lt;Document&gt; 
    &lt;Placemark&gt;
     &lt;name&gt;Gray Mesa&lt;/name&gt;
     &lt;description&gt;&lt;![CDATA[&lt;img width="800" src="1.jpg"/&gt;]]&gt;&lt;/description&gt;
     &lt;Point&gt;
      &lt;coordinates&gt;-106.493097,34.446357,1692.000000&lt;/coordinates&gt;
     &lt;/Point&gt;
    &lt;/Placemark&gt;
   &lt;/Document&gt;
  </code></pre>
  
  <p>I think this will work for my purpose. </p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:kml="http://www.opengis.net/kml/2.2"&gt;
     &lt;xsl:template match="/"&gt;
    &lt;xsl:for-each select="kml:kml/kml:Document/kml:Placemark"&gt;
       &lt;name&gt;&lt;xsl:value-of disable-output-escaping="yes" select="kml:name"/&gt;&lt;/name&gt;
       &lt;description&gt;&lt;xsl:value-of disable-output-escaping="yes" select="kml:description"/&gt;&lt;/description&gt;
    &lt;/xsl:for-each&gt;
   &lt;/xsl:template&gt;
  </code></pre>
  
  <p></p>
  
  <p>Each name and description tag includes this however: xmlns:kml="http://www.opengis.net/kml/2.2"
  I can just concatenate that with an Access query though. I do get an error when I try to import into Access though. It says I need a root folder since I only have numerous name and description tags. Is there any way to add a  tag using the XSL. Thank you very much. Sorry for the messy question that I keep editing.</p>