views:

129

answers:

2

I am trying to write out the following element using XmlWriter

<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"&gt;

I've got the very first declaration done using

writer.WriteStartElement("kml", "http://www.opengis.net/kml/2.2");

How can I add the remaining 3 declarations to the same element?

TIA

Thomas

A: 

The namespaces are simply attributes. Use the standards means of writing attributes for the element.

Francis Upton
+2  A: 
writer.WriteAttributeString("xmlns","gx", null, "http://www.google.com/kml/ext/2.2");
writer.WriteAttributeString("xmlns","kml", null, "http://www.opengis.net/kml/2.2");
writer.WriteAttributeString("xmlns","atom", null, "http://www.w3.org/2005/Atom");

Got that from http://msdn.microsoft.com/en-us/library/cfche0ka.aspx.

Ryan B
You are so nice, actually providing the code.
Francis Upton
Thanks Ryan! That works.
etechpartner