Click here to Skip to main content
12,356,784 members (65,781 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
public class ConvertedFilesMergeRule
{
   public List<string> MergingChannelIds { get; set; }
}

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

<MergeRule>
       <MergingChannelIds>
             <string>CTVCM</string>
             <string>TCM</string>
             <string>DTM</string>
       </MergingChannelIds>
</MergeRule>
Posted 22-Dec-12 9:00am
axe_ll164
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Try to write smth like that:

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>
  Permalink  
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()
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 =)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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...
    }
}
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100