C# check an element exists while using LINQ to XML

前端 未结 6 1007
慢半拍i
慢半拍i 2021-01-02 08:32

OK, bit of a random question, but the best way to do this is to just add the code, you\'ll be able to see what I mean straight away:

XML:



        
6条回答
  •  离开以前
    2021-01-02 08:52

    I would do it like this:

    var superType = linquee.Descendants("customer").
        Where(c => c.Element("SuperType") != null 
            && c.Element("SuperType").Value == "1");
    

提交回复
热议问题