How can I get single node data using linq

后端 未结 5 874
生来不讨喜
生来不讨喜 2021-01-29 09:27

I have the following xml file


  
    1
    Computer
    Infor         


        
5条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 09:48

    var xml = XDocument.Parse(xmlDataString);
    
    var categoryElement = xml.Root
        .Elements("category")
        .FirstOrDefault(e => (string)e.Element("id") == "1");
    

提交回复
热议问题