Pablo Costa

Pablo Costa

  • NA
  • 24
  • 4.5k

How to write a xml using a list

Feb 24 2016 5:24 PM
[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

Answers (8)