The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: XML Diff and Patch using LINQ to Xml and LINQ to Objects
3 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

sureshPosted Jan 17, 2013, 7:11 AM
nhg
Sireesha PisipatiPosted Jul 22, 2010, 4:41 PM
I have 2 XML files which look like <Menu> <Groups> <group name = "A"> <Command name="c1"> <opt>1</opt> <value>T</value> </Command> <Command name="c2"> <opt>2</opt> <value>E</value> </Command> <group name = "B"> <Command name = "c3"> <opt>3</opt> <value>N</value> <group name = "C"> <Command name = "c4"> <opt>5</opt> <value>H</value> </Command> </group> </group> </group> </Groups> </Menu> I need to create a merged xml file. the new file will have everything from file 1. Then I need to see if any of the <Command> tags within this file find a match on the Name attribute in file 2 at the same level of nesting, we should replace the <opt> and <value> tags under this <Command> tag in the merged file with values from file2. Any Commands in file2 should be added to the merged file with the hierarchy preserved. Is this doable using LINQ easily? Thanks
Santosh BenjaminPosted Nov 26, 2009, 6:16 PM
Hi, Excellent article. The one problem is that the sample 4 query for Intersect does not work. it returns null (using your sample solution and also in a separate solution just using the code copied from the article). Any ideas? Cheers, benjy