How to the replace node names with new name and keep the attributes using C# and Linq to XML? -


i need change

<test language="english" id="0" /> 

to

<exam language="english" id="0" /> 

how replace node names new name , keep attributes ?

you can use name property

var xdoc = xdocument.load("input.xml"); var nodes=xdoc.descendants("test").tolist();//get "test" node  nodes.foreach(d => d.name = "exam "); // set name 'exam' xdoc.save("output.xml"); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -