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

  • Home
  • SEARCH
  • 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 7507405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:28:50+00:00 2026-05-29T22:28:50+00:00

I have a table with following structure : id, – Primary key minlatitude –

  • 0

I have a table with following structure :

id, – Primary key

minlatitude – boundary point of a square

minlongitude – boundary point of a square
maxlatitude – boundary point of a square
maxlongitude- boundary point of a square

cetnerLatitude – Center of a sqaure
centerLonigtude – Center of a sqaure

The min max fields creates a square and center Lat/Long is for center point of the square.

I want to generate KML file using ” xml path “. The generated KML file should look similar to following:

<?xml version="1.0" encoding="UTF-8"?>
 <kml xmlns="http://www.opengis.net/kml/2.2">  
 <Document>
<Placemark>
  <name>example</name>
  <description>
dafdafdsaf
  </description>
  <Point>
    <coordinates>102.594411,14.998518</coordinates>
  </Point>
  <Polygon>
    <extrude>1</extrude>
    <altitudeMode>relativeToGround</altitudeMode>
    <outerBoundaryIs>
      <LinearRing>
        <coordinates>
          -77.05788457660967,38.87253259892824,100
          -77.05465973756702,38.87291016281703,100
          -77.05315536854791,38.87053267794386,100
          -77.05788457660967,38.87253259892824,100
        </coordinates>
      </LinearRing>
    </outerBoundaryIs>
  </Polygon>
</Placemark>
</Document>
</kml>"""

I started working around the xmlpath SQL query and so far got the following result:

declare @id int
set @id = 22438
declare @kml xml;

with XMLNAMESPACES(
        'http://www.opengis.net/gml' as gml,
        'http://www.georss.org/georss' as georss
)

select @kml = 
        (select some as id , 

        cast([cent_latt] as varchar) + ', ' + cast([cent_long] as varchar) as Point
        from mytable
        Where some = @id

        for xml path('Placemark'), root('Document')
        )

select @kml

Can anyone help generating the exact file as mentioned above?
Or is there a way to use xslt for the same?

  • 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-05-29T22:28:51+00:00Added an answer on May 29, 2026 at 10:28 pm

    I could not really understand what columns names you have for what information so I created a sample table that will show you how you can get the different parts into the XML.

    declare @T table
    (
      Name varchar(50),
      Description varchar(50),
      Point varchar(50),
      Extrude int,
      AltitudeMode varchar(50),
      Coordinates varchar(200)
    );
    
    insert into @T values
    ('example', 'dafdafdsaf', '102.594411,14.998518', 1, 'relativeToGround', 
    '-77.05788457660967,38.87253259892824,100
    -77.05465973756702,38.87291016281703,100
    -77.05315536854791,38.87053267794386,100
    -77.05788457660967,38.87253259892824,100');
    
    with xmlnamespaces(default 'http://www.opengis.net/kml/2.2')
    select (
           select Name as name,
                  Description as description,
                  Point as 'Point/coordinates',
                  (
                    select Extrude as extrude,
                           AltitudeMode as altitudeMode,
                           Coordinates as 'outerBoundaryIs/LinearRing/coordinates'
                    for xml path('Polygon'), type
                  )
           from @T       
           for xml path('Placemark'), type
           )
    for xml path('Document'), root('kml');
    

    Result:

    <kml xmlns="http://www.opengis.net/kml/2.2">
      <Document>
        <Placemark xmlns="http://www.opengis.net/kml/2.2">
          <name>example</name>
          <description>dafdafdsaf</description>
          <Point>
            <coordinates>102.594411,14.998518</coordinates>
          </Point>
          <Polygon xmlns="http://www.opengis.net/kml/2.2">
            <extrude>1</extrude>
            <altitudeMode>relativeToGround</altitudeMode>
            <outerBoundaryIs>
              <LinearRing>
                <coordinates>-77.05788457660967,38.87253259892824,100
    -77.05465973756702,38.87291016281703,100
    -77.05315536854791,38.87053267794386,100
    -77.05788457660967,38.87253259892824,100</coordinates>
              </LinearRing>
            </outerBoundaryIs>
          </Polygon>
        </Placemark>
      </Document>
    </kml>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I have table with following structure id int auto increment, primary key uid int
I have a table (session_comments) with the following fields structure: student_id (foreign key to
I have a table with the following structure uid sid eid Key value 1
I have a table with the following structure, FIELD TYPE EXTRA faciltiy_id int auto_increment(Primary
I have the following table structure Key int MemberID int VisitDate DateTime How can
I have already googled for this I have a Table with following structure in
I have a table emp with following structure and data: name dept salary -----
I have a table with the following structure id(int) | col1(int) | col2(int) |
I have the following table structure CREATE TABLE `table` ( `id` int(11) NOT NULL

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.