Question

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 :)

Was it helpful?

Solution

You'll need WriteAttributeString.

OTHER TIPS

As far as XML is concerned:

<Style id= "randomColorIcon"></Style>

And:

<Style id= "randomColorIcon" />

Are equivalent.

In that respect, the following will produce the semantic equivalent of what you are asking for:

kml.WriteStartElement("Style");
kml.WriteAttributeString("id", "randomColorIcon");
kml.WriteEndElement();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top