Writing the output of IEnumerable<XElement> to a XML File

Posted by Googler on Stack Overflow See other posts from Stack Overflow or by Googler
Published on 2010-05-01T13:21:35Z Indexed on 2010/05/01 13:27 UTC
Read the original article Hit count: 253

Filed under:

HI folks ,

This is my code to read two xml files and merge their elemnts. I want to write the output to an xml file.

This is my code.

IEnumerable<XElement> list0 =
                doc.Descendants(node1).Concat(doc2.Descendants(node2));
            foreach (XElement el in list0)
                Console.WriteLine(el);

Instead of writing to the console i need to write it to a xml file. Output is also in the xml format.How to achieve this. Can anyone pls give me a code or method to achiev this.

© Stack Overflow or respective owner

Related posts about file-io