1

How do I make this line in my xml? (the problem is the namespace)

The closes I came was this:

XDocument doc = new XDocument();
XElement root = new XElement("root", 
    new XAttribute("name", Name),
    new XAttribute(XNamespace.Xmlns, Namespace)//<-- XNamespace.Xmlns is not good
);

I have tryed with new XAttribute("xmlns", Namespace) also, but I just don't get it.

radbyx
  • 9,352
  • 21
  • 84
  • 127

1 Answers1

1

I found this. It works great.

XDocument doc = new XDocument();
XElement root = new XElement("root", 
    new XAttribute("name", Name)
    );
doc.Add(root);
XNamespace xmlns = Namespace;
doc.Root.Name = xmlns + root.Name.LocalName;
radbyx
  • 9,352
  • 21
  • 84
  • 127