Using C# Generics read & update XML file .

public  List < XmlElement >  GetNodeList()
        {
            list 
=   new  List < XmlElement > ();
            XmlNode nodeFirst= document.SelectSingleNode("Ele\NodeFirst"));
            XmlNode nodeSecond= document.SelectSingleNode("Ele\NodeSecond"));
            list.Add(nodeFirst); 
            list.Add(nodeTwo);    
            
return  list;
        }
 List<XmlElement> Newlist = GetNodeList();
 

foreach (XmlElement item in Newlist )
   {
    Console.WriteLine("\t{0}\t{1}\t{2}",item.value
}

NewList.Remove(nodeTwo);


 

FYI : http://panjunlai.blog.163.com/blog/static/581903012010420781664/

你可能感兴趣的:(generics)