LINQ to XML: How to select the next element

后端 未结 4 1327
慢半拍i
慢半拍i 2021-01-04 03:25

I have a plist file from an iPhone app. It looks like this below:


  
    barcodes
    

        
4条回答
  •  一整个雨季
    2021-01-04 03:54

    var q = xml
            .Descendants("plist")
            .Descendants("dict")
            .Where(item => item.Value == "jobSteps")
            .Select(item => item.NextNode)
            .SingleOrDefault() // add this if you expect single match
            ;
    

    The q will be either a single array node or a sequence of array nodes depending whether you use SingleOrDefault().

提交回复
热议问题