Linq to XML when data held in a list -


I have a list of strings that I need to use to create the following XML I items in the list "Line 1 "," Line 2 "etc. The hard bit is that the element name "L1" grows upwards, is it possible to use linux to do this or should I use a different approach?

  & lt; Srv & gt; & Lt; EnqRsp & gt; & Lt; L1 & gt; Line 1 & lt; / L1> & Lt; L2 & gt; Line 2 & lt; / L2 & gt; & Lt; L3 & gt; Line 3 & lt; / L3 & gt; & Lt; L4 & gt; Line 3 & lt; / L4 & gt; & Lt; / EnqRsp & gt; & Lt; / SRV & gt;  

This is entirely possible, with the help of which the index provides value as well Is:

  var document = new XDocument (new XElement ("srv", new XElement ("enqRsp", list.Select ((value, index) = & gt; new XElement ("l "+ (Index + 1), value))));  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -