views:

21

answers:

1

I have an XPathNavigator object pointing to an XML element. I want to rename the element to another name (and also rename the associated end element). Can this be done using the XPathNavigator?

(I have a work-around, which is to Delete the element and re-insert it under a different name, but this may cause a performance issue, because I am handling very large documents)

A: 

It depends on what your underlying XML document representation is. If you are using XDocument you can do:

(XElement)(navigator.UnderlyingObject).Name = ...

I don't think it is possible with XmlDocument (except as you suggest), or XPathDocument.

Nick Jones
Unfortunately, my underlying document is a XmlDocument. I will have stick with the workaround. Thank you. http://stackoverflow.com/questions/847951/net-import-xmlelement-with-different-element-name
decasteljau