Xdocument = new xdocument (<br/> New xelement ("bookpays", firstpays = <br/> New xelement ("bookpays ", <br/> New xcomment ("this is a new author. "), <br/> New xattribute (" type "," author "), <br/> New xelement (" firstname "," Joe "), <br/> New xelement ("lastname", "rattz"); </P> <p> console. writeline ("before updating nodes:"); <br/> console. writeline (xdocument); </P> <p> // now, lets update an element, a comment, and a text node. <br/> firstparticipant ipant. element ("firstname "). value = "Joey"; <br/> firstparticipant ipant. nodes (). oftype <xcomment> (). single (). value = <br/> "author of pro LINQ: Language Integrated Query in C #2008. "; <br/> (xelement) firstparticipant ipant. element ("firstname "). nextnode) <br/>. nodes (). oftype <xtext> (). single (). value = "rattz, Jr. "; </P> <p> console. writeline ("after updating nodes:"); <br/> console. writeline (xdocument );
Output
Before updating nodes: <br/> <bookpays> <br/> <bookpays type = "author"> <br/> <! -- This is a new author. --> <br/> <firstname> Joe </firstname> <br/> <lastname> rattz </lastname> <br/> </bookparticipant ipant> <br/> </ bookparticipant ipants> <br/> after updating nodes: <br/> <bookpays> <br/> <bookpays type = "author"> <br/> <! -- Author of pro LINQ: Language Integrated Query in C #2008. --> <br/> <firstname> Joey </firstname> <br/> <lastname> rattz, Jr. </lastname> <br/> </bookparticipant ipant> <br/> </bookparticipant ipants>