[Walk trough list and write XML]
Hi everyone.
I'm kinda stuck on a part of my code.
I've a list on wich every position receives an xmldata (custom class). It contains three positions (colorname, colorvalue and xml_filename).
On my method to write xml , i'm trying to setup a foreach statement to write an XML for each xml_filename
i.e: Positions from 0 to 4 have a xml_filename called bla.ppf , positions 5 to 9 have a xml_filename called ble.ppf .
How could i walk trough my list , write the XML based on each xml_filename field of the list ?
I've readed about linq methods for converting the list to xml directly but i know nothing about linq (c# newbie)
Basically: each list position has tree elements from my custom class. The element xml_filename determines which file the field belongs and its attributes. The foreach loop should be something like (foreach item in xmllist) , write one xml using fields where xml_filename is equal (from positions 0 to 5 , example). From positions 6 to 9 another file (field xml_filename will change) and so goes on.
I've posted the whole code on pastebin (big to post here). Thanks !
http://pastebin.com/nrXhumev
Loading

ali tuncerRank #1,499 · 1.1K reputationPosted Feb 25, 2016, 3:40 PM EST
foreach (var filename in grouped)
{
//will take List
writexml(XList.FullList.Where(i => i.xml_filename == filename.Key).ToList(), v);
}
ali tuncerRank #1,499 · 1.1K reputationPosted Feb 25, 2016, 1:20 AM EST
//first group by file names..
var grouped = XMLList.FullList.GroupBy(s => s.xml_filename).Select(grp => new {grp.Key});
foreach (var filename in grouped)
{
WriteToXml(XMLList.FullList.Where(i => i.xml_filename == filename.Key).ToList());
}
ali tuncerRank #1,499 · 1.1K reputationPosted Feb 24, 2016, 4:11 PM EST
I guess like this :
foreach (xmldata item in XMLList.FullList)
{
}
Pablo Costa24 reputationPosted Feb 24, 2016, 5:47 PM EST
Chandu KumawatRank #1,449 · 1.1K reputationPosted Feb 25, 2016, 1:26 AM EST
Chandu KumawatRank #1,449 · 1.1K reputationPosted Feb 25, 2016, 1:27 AM EST
Pablo Costa24 reputationPosted Feb 25, 2016, 3:46 AM EST
Pablo Costa24 reputationPosted Feb 25, 2016, 6:56 PM EST