How can I transform XML into a List or String[]?

后端 未结 8 1746
半阙折子戏
半阙折子戏 2020-12-01 08:19

How can I transform the following XML into a List or String[]:


  1
  2<         


        
8条回答
  •  再見小時候
    2020-12-01 09:02

    This sample will work with the .NET framework 3.5:

        System.Xml.Linq.XElement element = System.Xml.Linq.XElement.Parse("  1  2");
        System.Collections.Generic.List ids = new System.Collections.Generic.List();
        foreach (System.Xml.Linq.XElement childElement in element.Descendants("id"))
        {
            ids.Add(childElement.Value);
        }
    

提交回复
热议问题