How to get element content using only XPath and C# .NET

前端 未结 3 1416
粉色の甜心
粉色の甜心 2021-01-13 23:56

I\'ve found a lot of articles about how to get node content by using simple XPath expression and C#, for example:

XPath:

/bookstore/author/first-nam         


        
3条回答
  •  隐瞒了意图╮
    2021-01-14 00:26

    You can use Linq to XML as well to get value of specified element

    var list = XDocument.Parse("xml string").Descendants("ParaLine")
                     .Select(x => x.Element("string").Value).ToList();
    

    From above query you will get value of all the string element which are inside ParaLine tag.

提交回复
热议问题