【发布时间】:2010-04-22 15:48:00
【问题描述】:
XNamespace xnRD = "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner";
XNamespace xnNS = "http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition";
XAttribute xaRD = new XAttribute(XNamespace.Xmlns + "rd", xnRD);
XAttribute xaNS = new XAttribute("xmlns", xnNS);
XElement x =
new XElement("Report", xaRD, xaNS,
new XElement("DataSources"),
new XElement("DataSets"),
new XElement("Body"),
new XElement("Width"),
new XElement("Page"),
new XElement("ReportID", xaRD),
new XElement("ReportUnitType", xaRD)
);
XDocument doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
doc.Add(x);
Console.WriteLine(doc.ToString());
导致运行时错误:
{"前缀 '' 不能在同一个起始元素标记内从 '' 重新定义为 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'。"}
我想做的只是让 DataSources 和 DataSets 写出到 Debug.Console 以构建 ObjectDataSources,因为 VS2010 忽略了为 ASPX 添加它们。
编辑:
new XElement(xaRD + "ReportID"),
new XElement(xaRD + "ReportUnitType")
改变并得到:
附加信息:“:”字符,十六进制值 0x3A,不能包含在名称中。
相反
【问题讨论】: