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
Post a Comment