Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public class ConvertedFilesMergeRule
{
   public List<string> MergingChannelIds { get; set; }
}


C#
MergeRule = (from e in doc.Descendants("MergeRule")
                           select new ConvertedFilesMergeRule()
                           {
                                    MergingChannelIds= ??????????
                           }).ToList<ConvertedFilesMergeRule>


XML
<MergeRule>
       <MergingChannelIds>
             <string>CTVCM</string>
             <string>TCM</string>
             <string>DTM</string>
       </MergingChannelIds>
</MergeRule>
Posted

Try to write smth like that:

C#
MergeRule = (from e in doc.Descendants("MergeRule")
             let tmp=e
                           select new ConvertedFilesMergeRule()
{
                         MergingChannelIds= (from item e.Descendants("MergingChannelIds") select item.Value).ToList();
                           }).ToList<ConvertedFilesMergeRule>
 
Share this answer
 
Comments
axe_ll 22-Dec-12 16:16pm    
Thank You thank you very much! :-)
MergeRule = (from e in doc.Descendants("MergeRule")
let tmp=e
select new ConvertedFilesMergeRule()
{MergingChannelIds= (from item in
e.Descendants("MergingChannelIds") select item.Value).ToList()
}).First<convertedfilesmergerule>()
Oleksandr Kulchytskyi 22-Dec-12 16:21pm    
You are welcome,Sorry but obviously, i have misspelled smth in that LINQ, just remove line -> let tmp=e, this is redundancy line of code =)
C#
using System.IO;
using System;
using System.Collections.Generic;
using System.Xml;

class MyClass
{
    int main()
    {
       List<string> strings = new List<string>();

       string file = @"C:\example.txt";
       StreamReader sr = new StreamReader(file);
       XmlTextReader tr = new XmlTextReader(sr);
       while(tr.Read())
       {
          if (tr.NodeType == XmlNodeType.Text)
              strings.Add(tr.Value)
       }
       tr.Close();
       sr.Close();

       //Do stuff...
    }
}
 
Share this answer
 
v2
Comments
axe_ll 22-Dec-12 15:44pm    
I need to get the object because ConvertedFilesMergeRuleis part of another object

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900