【发布时间】:2012-04-06 12:25:40
【问题描述】:
我正在创建一个 XDocument,如下所示。对于 TestId、LoginData 和 InterfaceVersion 元素,输出具有 xmlns = ""。我不希望 xmlns = "" 用于这些元素。如何抑制这种情况?
XNamespace aw = "http://test.com/xml/DatabaseService/TestData";
XDocument xw = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
new XElement(aw + "TestData", new XAttribute("version", "1.0"),
new XElement("TestId", new XAttribute("Id", strPublishedId)),
new XElement("LoginData", new XAttribute("User", "none"), new XAttribute("Password", "nothing"), new XAttribute("Domain", "")),
new XElement("InterfaceVersion", new XAttribute("Major", "1"), new XAttribute("Minor", "0"))));
提前致谢。
【问题讨论】:
标签: xml linq-to-xml xml-parsing