Rename an XmlElement?


#1

I've got a structure of XmlElement and I want to rename some of them, keeping all their child elements intact?  Any suggestions?  It doesn't appear obvious, except by walking through all the existing child elements of the one I'm renaming, adding them to a new Element and inserting that ... ?


#2

Feels like a strange thing to want to do.. That's why I never added a method to set the name.

Sure, what you suggested will work, but the fact that the class has been around for 10 years and you're the first person to ask for such a method should be a bit of a warning sign! Certainly if I was writing code to transform one type of XML into another, I'd just do it cleanly and build a new tree rather than trying to hammer the old one into the correct shape.