how do I avoid getting the empty namespace in newly created XElement?

holeefcuk

New Member
I am trying to delete then add a pageFooter to an xml document from a different file: \[code\]XNamespace rep = "http://developer.cognos.com/schemas/report/8.0/";//remove pageFooterdoc.Root.Descendants().Where(e=>e.Name == rep + "pageFooter").Remove();//create and load pagefooter from fileXElement pageFooter = XElement.Load(@"C:\pageFooter.xml");\[/code\]and I am getting the empty namespace:\[code\]<pageFooter xmlns=""> <contents> ..............\[/code\]I tried all of the following to add the namespace to the new element, nothing works:\[code\]XElement pagefooter = new XElement(rep+"pageFooter"); pageFooter = XElement.Load(@"C:\pageFooter.xml"); //this has no effectpageFooter.Name = rep.GetName(pageFooter.Name.LocalName);//this moves the xmlns="" to the next descendant, <contents>pageFooter.Add(rep); //this has no effectpageFooter.SetAttributeValue("xmlns", rep);//this results an empty pageFooter\[/code\]Any ideas? Thanks!!
 
Back
Top