Search code examples
c#asp.netquoteskmlxmltextwriter

How to write quotation marks in KML through C# code


maybe a stupid question here but my html skills are faded now.. :)

I am creating a KML file with a button click and all the code for the KML tags is there. What I need is using more than one tags. It will be hardcoded in the beginning of the KML. The KML should look something like this:

KML with 2 Style id

So this code is generated from the C# code behind. So the question is how to get

<Style id= "randomColorIcon">

and then close the tag properly like /Style without having the id part?

In the C# code I had something like this but I just found that it doesn't read the other Style id tags

kml.WriteStartElement("Style");
  kml.WriteElementString("id", "randomColorIcon"); //not suitable for more than one Style tags
  kml.WriteStartElement("IconStyle");
  kml.WriteStartElement("Icon");
  kml.WriteElementString("href",      "http://maps.google.com/mapfiles/kml/pal3/icon23.png");
  kml.WriteEndElement(); //</Icon>
  kml.WriteEndElement(); //</IconStyle> ??
  kml.WriteEndElement(); //</Style> 

Thanks in advance :)


Solution

  • You'll need WriteAttributeString.