मैंने कोशिश की:XDocument के लिए xmlns निर्दिष्ट कैसे करें?
textBox1.Text = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"),
new XElement("root1", new XAttribute("xmlns", @"http://example.com"), new XElement("a", "b"))
).ToString();
लेकिन मैं मिलता है:
The prefix '' cannot be redefined from '' to 'http://example.com' within the same start element tag.
मैं भी प्रतिस्थापन की कोशिश की (एक जवाब मैंने पाया के अनुसार):
XAttribute(XNamespace.Xmlns,...
लेकिन एक त्रुटि के रूप में अच्छी तरह से मिला है।
नोट: मैं दस्तावेज़ में एक से अधिक xmlns रखने की कोशिश नहीं कर रहा हूं।
शायद यह आपके लिए काम करता है: http://stackoverflow.com/a/2874572/1373170 –