Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7816845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:01:18+00:00 2026-06-02T06:01:18+00:00

Hi I’m trying to use the w3schools XSLT Tryit editor to transform a KML

  • 0

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:

<?xml version="1.0" encoding="UTF-8"?>
<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">
 <Document>
  <name>Bnsf RR cut</name>
  <open>1</open>
  <Style>
   <ListStyle>
    <ItemIcon>
     <href>kmzicon.png</href>
    </ItemIcon>
   </ListStyle>
  </Style>
  <Folder>
   <name>11/10/11 8:17:20 AM</name>
   <Placemark>
    <name>Track</name>
   </Placemark>
  </Folder>
  <Placemark>
   <name>Gray Mesa</name>
   <description><![CDATA[<img width="800" src="1.jpg"/>]]></description>
   <Point>
    <coordinates>-106.493097,34.446357,1692.000000</coordinates>
   </Point>
  </Placemark>
 </Document>
</kml>

And my XSLT:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
      <xsl:for-each select="Document/Placemark">
        <xsl:value-of select="name"/>
        <xsl:value-of select="description"/>
      </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

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!

What I would like my transformed XML to look like:

 <Document> 
  <Placemark>
   <name>Gray Mesa</name>
   <description><![CDATA[<img width="800" src="1.jpg"/>]]></description>
   <Point>
    <coordinates>-106.493097,34.446357,1692.000000</coordinates>
   </Point>
  </Placemark>
 </Document>

I think this will work for my purpose.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:kml="http://www.opengis.net/kml/2.2">
   <xsl:template match="/">
  <xsl:for-each select="kml:kml/kml:Document/kml:Placemark">
     <name><xsl:value-of disable-output-escaping="yes" select="kml:name"/></name>
     <description><xsl:value-of disable-output-escaping="yes" select="kml:description"/></description>
  </xsl:for-each>
 </xsl:template>

Each name and description tag includes this however: xmlns:kml=”http://www.opengis.net/kml/2.2&#8243;
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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:01:21+00:00Added an answer on June 2, 2026 at 6:01 am

    Tim C is correct about the namespaces, but I’d like to add that XSLT is declarative language so usually when I see for-each in stylesheets it can be replace by something more fitting the language. So I would using the following code.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:kml="http://www.opengis.net/kml/2.2">
      <xsl:output method="text"/>
    
       <xsl:template match="/">
          <xsl:apply-templates select="kml:kml/kml:Document/kml:Placemark"/>
       </xsl:template>
    
       <xsl:template match="kml:Placemark">
             <xsl:value-of select="kml:name"/>
             <xsl:value-of select="kml:description"/>
       </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am trying to understand how to use SyndicationItem to display feed which is
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a reasonable size flat file database of text documents mostly saved in
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.