I want create an xml document with the namepace attributes along the lines of this:
<MyXmlDoC xmlns='http://abc' xmlns:brk='http://123'>
Using the System.Xml.Linq xml library, iv done this:
public static XAttribute XmlNamepace() { return new XAttribute(XName.Get('xmlns'), 'http://abc'); } public static XAttribute brkNamepace() { return new XAttribute(XNamespace.Xmlns + 'brk', 'http://123'); } var rootNode = new XElement('MyXmlDoC',XmlNamepace(),brkNamepace());
But this produces this error:
The prefix ” cannot be redefined from ” to ‘http://abc‘ within the same start element tag
What am I doing wrong
(From your answer) you need to add the ChildNode with the rt namespace, this should work: