Tôi có Chương trình C# để tạo tệp RDL cho whitch Hiển thị báo cáo trong dịch vụ báo cáo. Tôi sử dụng LINQ to Xml để tạo Xml.Thêm thuộc tính xmlns vào phần tử gốc
Khi tôi cố thêm xmlns XAttribute vào phần tử báo cáo, tôi gặp phải một số sự cố.
tôi thử nghiệm phương pháp sau đây:
đầu tiên:
XDocument d = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("Report",
new XAttribute(XNamespace.Xmlns + "rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"),
new XAttribute(XNamespace.Xmlns + "cl", "http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition"),
new XAttribute("xmlns", "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"),
new XElement("DataSources", ""),
new XElement("DataSets", ""),
new XElement("ReportSections",
này là một phần của mã phù thủy chương trình của tôi như thế nào tạo ra xml:
thứ hai:
XNamespace reportDef = "http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition";
XDocument d = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement(reportDef + "Report",
new XAttribute(XNamespace.Xmlns + "rd", "http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"),
new XAttribute(XNamespace.Xmlns + "cl", "http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition"),
new XElement("DataSources", ""),
new XElement("DataSets", ""),
new XElement("ReportSections",...
Phương thức đầu tiên trả về một lỗi và phương thức thứ hai thêm thuộc tính xmlns cho tất cả nút con.
Tôi muốn định dạng này:
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">
Tôi sử dụng giải pháp này nhưng không may là trước khi thuộc tính này thêm vào tất cả các nút con. –
Có vẻ lạ vì tôi không thể tái tạo điều này.Hãy thử thêm thuộc tính không gian tên mặc định như trong ví dụ thứ hai của tôi. Có thể cập nhật câu hỏi của bạn và hiển thị thêm mã thực của bạn. – Filburt
Thật không may nó như trước –