Question

Is it possible to rename a root element in an XML file using either XmlConfig or XmlFile? For example:

<config>
  <settings>
    <some setting="true" />
    ....
   </settings>
</config>

I want to rename "settings" while keeping everything in between the settings tags. So I'd like the result to be:

<config>
  <NEWsettings>
    <some setting="true" />
    ....
   </NEWsettings>
</config>
Was it helpful?

Solution

You cannot rename elements but you can copy all of them to a new node and delete the old node. Not ideal but you can let XmlConfig do the heavy lifting by adding temporary records to the table as answered in this question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top