c# - Merge nodes of the same kind to a single node -


i'm trying merge 2 nodes of same kind single node

so having both nodes this

<clubs>   <spe>accepted</community>   <scu>accepted</scu> </clubs> 

and this

<clubs>   <bus>declined</bus> </clubs> 

it become this

<clubs>   <spe>accepted</spe>   <scu>accepted</scu>   <bus>declined</bus> </clubs> 

how achieve such thing?

this might you

           xmldocument mydocument = new xmldocument();            mydocument.load(xmlfile);            var nodetoadd = mydocument.childnodes.oftype<xmlelement>().where(nodevariant => nodevariant.name == "clubs").selectmany(o => o.childnodes.oftype<xmlelement>()).tolist();            var nodetodelete = mydocument.childnodes.oftype<xmlelement>().where(nodevariant => nodevariant.name == "clubs");            foreach (var m in nodetodelete)            {                mydocument.removechild(m);            }              xmlnode newnode = mydocument.createelement("clubs");             foreach(var m in nodetoadd)             {             newnode.appendchild(m);             }             mydocument.appendchild(newnode);             mydocument.save(xmlfile); 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -