C# 如何添加一个简单的名称空间?
如何在xml中生成这一行?(问题是名称空间) 我来的目的是:C# 如何添加一个简单的名称空间?,c#,xml,xml-namespaces,linq-to-xml,C#,Xml,Xml Namespaces,Linq To Xml,如何在xml中生成这一行?(问题是名称空间) 我来的目的是: XDocument doc = new XDocument(); XElement root = new XElement("root", new XAttribute("name", Name), new XAttribute(XNamespace.Xmlns, Namespace)//<-- XNamespace.Xmlns is not good ); XDocument doc=new XDocum
XDocument doc = new XDocument();
XElement root = new XElement("root",
new XAttribute("name", Name),
new XAttribute(XNamespace.Xmlns, Namespace)//<-- XNamespace.Xmlns is not good
);
XDocument doc=new XDocument();
XElement根=新的XElement(“根”,
新XAttribute(“名称”,名称),
新的XAttribute(XNamespace.Xmlns,Namespace)/我找到了这个。它工作得很好
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;
我发现了这个,它很好用
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;