How to Return pure XML (no WS)

  • Thread starter Thread starter Stefano Peduzzi
  • Start date Start date
S

Stefano Peduzzi

Hi,
I've to return an XML (a KML for Google Earth) from my Web Server. How can I
do it with ASP.NET 2.0???
These are the requirements for a "KML Server" as stated by Google:
KML Server requirements
When responding to a request from the Google Earth client, a KML server must
follow a certain set of rules so that the client can correctly interpret
responses.

Upon success, the server must return a response code of HTTP 200 and set the
response's content-type to a suitable MIME type.
Google Earth reads KML and KMZ files, and the MIME types for these are:
application/vnd.google-earth.kml+xml kml
application/vnd.google-earth.kmz kmz
The body of the response must contain valid KML data, including the xml
declaration header (<?xml version="1.0" encoding="UTF-8"?>). If the server
returns invalid KML, the Network Link will stop deactivate and output an
error message.

Thanks,
Stefano
 
Create an HttpHandler that sets the Response.ContentType to the proper MIME
type and does a Response.Write of the output xml.

HTH,

Matt Dinovo
 
Response.ContentType="application/vnd.google-earth.kml+xml kml";
XmlDocument doc = new XmlDocument();
doc.LoadXml("your Xml document string here"); // or use doc.Load overload
Response.Write (doc.OuterXml);
Response.End();

Peter
 
Hello Stefano,
Hi,
I've to return an XML (a KML for Google Earth) from my Web Server. How
can I
do it with ASP.NET 2.0???
These are the requirements for a "KML Server" as stated by Google:
KML Server requirements
When responding to a request from the Google Earth client, a KML
server must
follow a certain set of rules so that the client can correctly
interpret
responses.
Upon success, the server must return a response code of HTTP 200 and
set the
response's content-type to a suitable MIME type.
Google Earth reads KML and KMZ files, and the MIME types for these
are:
application/vnd.google-earth.kml+xml kml
application/vnd.google-earth.kmz kmz
The body of the response must contain valid KML data, including the
xml
declaration header (<?xml version="1.0" encoding="UTF-8"?>). If the
server
returns invalid KML, the Network Link will stop deactivate and output
an
error message.

The best approach is to implement a HttpHandler that sets HttpResponse.ContentType
to one of those mentioned above and writes KML to your HttpResponse's OutputStream.
There's really nothing special here.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top