Hi,
From an ASP.NET application I am loading an xml-file in order to modify it.
This is part of the code I have produced so far:
XmlDocument XMLDoc = new XmlDocument();
XmlNamespaceManager nsmanager = new XmlNamespaceManager(XMLDoc.NameTable);
nsmanager.AddNamespace("rd",
"http://schemas.microsoft.com/SQLServer/reporting/reportdesigner");
nsmanager.PushScope();
nsmanager.AddNamespace("aa",
"http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition" );
XmlNode root;
XMLDoc.Load(Server.MapPath("ReportTemplate.xml"));
root = XMLDoc.DocumentElement ;
System.Xml.XmlNode TableColumns =
root.SelectSingleNode("descendant::aa:TableColumns ", nsmanager);
XmlElement tablecolumn = XMLDoc.CreateElement("TableColumn");
XmlElement width = XMLDoc.CreateElement("Width");
width.InnerText = "4.0cm";
tablecolumn.AppendChild(width);
TableColumns.AppendChild(tablecolumn);
This however has the disadvantage of adding namespace declarations to the
TableColumn node:
<TableColumn xmlns="">
How can I avoid the empty namespace declaration in the TableColumn node? I'd
prefer not to use the XmlTextWriter instead of DOM, since I need to do quite
a lot of modifications to the XML file.
Thanks for any suggestions.
Dorte