Ho un programma C# per generare file RDL Per mostrare il rapporto nei servizi di segnalazione. Io uso Linq per Xml per generare Xml.Aggiungi l'attributo xmlns all'elemento radice
Quando provo ad aggiungere xmlns XAttributo a Report Element, ho riscontrato diversi problemi.
I test seguenti metodi:
primi:
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",
Questa è una parte del mio codice strega mostrano come generare codice XML:
secondo:
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",...
Il primo metodo restituisce un errore e il secondo metodo aggiunge l'attributo xmlns a tutti i nodi figlio.
Voglio questo formato:
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">
Io uso questa soluzione, ma purtroppo come prima questo attributo aggiungere a tutti i figli. –
Sembra strano dal momento che non riesco a riprodurre questo.Prova ad aggiungere l'attributo namespace predefinito come nel mio secondo esempio. Forse aggiorna la tua domanda e mostra altro del tuo codice attuale. – Filburt
Sfortunatamente come prima –