johnpapa

johnpapa

  • NA
  • 2
  • 0

XmlDataDocument problem: xmlns

Jul 21 2004 10:27 AM
Hello all, Im trying to manipulate a config file using XmlDataDocument. The config file is as follows: I Want to be able to change the versioning informayion without affecting the rest of the file, so I use the following code: XmlDataDocument doc = new XmlDataDocument(); doc.Load(configFile); XmlNode temp = doc.FirstChild; while(!temp.Name.Equals("dependentAssembly")) { temp = temp.FirstChild; } XmlElement newNode = doc.CreateElement("bindingRedirect"); newNode.SetAttribute("oldVersion","0.0.0.0 - 9999.9999.9999.9999"); newNode.SetAttribute("newVersion",a[0].AssemblyVersion); temp.ReplaceChild(newNode, temp.LastChild); doc.Save(configFile); But, instead of getting: , i get: I really dont have a clue why this happens! And it only happens if the xmlns attribute exists in the assemblyBinding element of the xml document. Could someone please help? I have searched the internet so many times, but I couldn't find anything. As you can understand I don't know anything about xml. I just need to be able to replace this element. Any help will be greately appreciated! Thanx!

Answers (1)