.NET 3.5 является опцией?
XNamespace ns = "http://www.w3.org/2001/XMLSchema-instance";
string s = new XElement("AmazonEnvelope",
new XAttribute(XNamespace.Xmlns + "xsi", ns),
new XAttribute(ns + "noNamespaceSchemaLocation", "amzn-envelope.xsd")
).ToString();
или с XmlWriter
:
const string ns = "http://www.w3.org/2001/XMLSchema-instance";
writer.WriteStartDocument();
writer.WriteStartElement("AmazonEnvelope");
writer.WriteAttributeString("xmlns", "xsi", "", ns);
writer.WriteAttributeString("xsi", "noNamespaceSchemaLocation",
ns, "mzn-envelope.xsd");
writer.WriteEndDocument();