Answered by:
Using Linq to concatonate xml files. Is thsi correct?

Question
-
Hi I'm trying to concatonate multiple xml files into one file. I had the option to do this through xml and xsl routines but I read that it could be done using Linq which I want to learn about. The problem I am having is that the method fails at a point with no error but no result either and I wanted to check to see if I'm doing things correctly:
The code :
List<XDocument> processingList = new List<XDocument>(); //processed list containing the files to be concatonated foreach (XMLHandler xdoc in activeQuestions) { processingList.Add(XDocument.Load(xdoc.translatorLocation.ToString() + ".xml")); } if (processingList.Count > 1) { for (int i = 1; i < processingList.Count; i++) var finalList = processingList[i - 1].Descendants("AllNodes").Union(processingList[i].Descendants("AllNodes")); }
var finalList never seems to have an output, any ideas why?
- Moved by Harry Zhu Thursday, May 27, 2010 7:13 AM (From:Visual C# Language)
Friday, May 21, 2010 12:41 PM
Answers
-
Hi,
The question relating to linq is beyond the scope of this forum, I suggest you try this forum:
http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/threads/
Thanks,
Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Proposed as answer by Ed Price - MSFTMicrosoft employee Saturday, December 24, 2011 7:20 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Saturday, December 24, 2011 7:21 AM
Thursday, May 27, 2010 7:11 AM -
This was moved out of the C# forum.
I can move it into a specific XML or Linq forum if you'd like.
This is regarding your code:
List<XDocument> processingList = new List<XDocument>(); //processed list containing the files to be concatonated foreach (XMLHandler xdoc in activeQuestions) { processingList.Add(XDocument.Load(xdoc.translatorLocation.ToString() + ".xml")); } if (processingList.Count > 1) { for (int i = 1; i < processingList.Count; i++) var finalList = processingList[i - 1].Descendants("AllNodes").Union(processingList[i].Descendants("AllNodes")); }
Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)- Proposed as answer by Ed Price - MSFTMicrosoft employee Saturday, December 24, 2011 7:20 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Saturday, December 24, 2011 7:20 AM
Saturday, December 24, 2011 7:20 AM
All replies
-
Hi,
The question relating to linq is beyond the scope of this forum, I suggest you try this forum:
http://social.msdn.microsoft.com/forums/en-US/linqprojectgeneral/threads/
Thanks,
Harry
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Proposed as answer by Ed Price - MSFTMicrosoft employee Saturday, December 24, 2011 7:20 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Saturday, December 24, 2011 7:21 AM
Thursday, May 27, 2010 7:11 AM -
This was moved out of the C# forum.
I can move it into a specific XML or Linq forum if you'd like.
This is regarding your code:
List<XDocument> processingList = new List<XDocument>(); //processed list containing the files to be concatonated foreach (XMLHandler xdoc in activeQuestions) { processingList.Add(XDocument.Load(xdoc.translatorLocation.ToString() + ".xml")); } if (processingList.Count > 1) { for (int i = 1; i < processingList.Count; i++) var finalList = processingList[i - 1].Descendants("AllNodes").Union(processingList[i].Descendants("AllNodes")); }
Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)- Proposed as answer by Ed Price - MSFTMicrosoft employee Saturday, December 24, 2011 7:20 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Saturday, December 24, 2011 7:20 AM
Saturday, December 24, 2011 7:20 AM