eat-sleep-code
eat-sleep-code

Reputation: 4865

C# XmlWriter Syntax To Write Multiple Namespace Tags

I am attempting to write the following line with C#'s XmlWriter.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">

I seem to only seem have an option to write on xmlns (and then with no :suffix), when using the xmlWriter.WriteStartElement method.

Is it possible to do with XmlWriter?

Upvotes: 0

Views: 642

Answers (1)

Joshua
Joshua

Reputation: 552

Would this help? Adjusted to use LookupPrefix.

writer = XmlWriter.Create(sw);
writer.WriteStartElement("configuration");
writer.WriteAttributeString("xmlns", "patch", null, "http://www.sitecore.net/xmlconfig/");
writer.WriteAttributeString("xmlns", "set", null, "http://www.sitecore.net/xmlconfig/set/");
writer.WriteEndElement();
writer.Flush();
writer.Close();

outputs:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" />

Upvotes: 1

Related Questions