Add xmlns attribute to root element

Dragonlordgod

New Member
I have C# Program to Generate RDL File For whitch Show report in Reporting services.I use Linq to Xml to generate Xml.When I try to add xmlns XAttribute to Report Element, I encounter several problems.I test following methods:first:\[code\] 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",\[/code\]this is a part of my code witch show how generate xml:second:\[code\]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",...\[/code\]The first method returns an Error and second method adds attribute xmlns to all child node.I want this format:\[code\]<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">\[/code\]
 
Back
Top