How to read XML via c# such as

前端 未结 2 1340
孤独总比滥情好
孤独总比滥情好 2021-01-17 03:20

I want to know how to get attribute \"text\" via c#?

Example xml:



         


        
2条回答
  •  难免孤独
    2021-01-17 03:50

    You could use XDocument and LINQ

    You'll need to include the System.Xml.Linq.XDocument namespace.

    Then you could do something like:

     XDocument document = XDocument.Load(filePath);
     var modes = (from modes in document.Root.Descendants("Mode")
                  select modes.Attribute("Name").Value).ToList();
    

提交回复
热议问题