LINQ to XML. How to get some string?

后端 未结 2 634
旧巷少年郎
旧巷少年郎 2021-01-25 18:29

I have xml:



  
    Ray
    Other         


        
2条回答
  •  一生所求
    2021-01-25 19:34

    Xpath can simplify your code

    var covers = xDoc.XPathSelectElements("//cover[@size='mini']").ToList();    
    

    to get the inner text

    var covers = xDoc.XPathSelectElements("//cover[@size='mini']")
                    .Select(x => x.Value)
                    .ToList(); 
    

提交回复
热议问题