Click here to Skip to main content
Rate this: bad
good
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 10: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 at 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 at 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 at 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
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 BillWoodruff 170
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2014
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