LINQ to XML query attributes

后端 未结 3 450
一整个雨季
一整个雨季 2021-01-13 04:30

using LINQ to XML, this is a sample of my XML


 
   

        
3条回答
  •  鱼传尺愫
    2021-01-13 05:14

    Here's another way of doing it:

       var nodes = xmlFile.Nodes()
      .OfType()
        .DescendantNodes()
      .OfType()
        .Where(x => x.Name.LocalName == "Event" && x.Attribute("Code").Value.Contains("456"));
    foreach (var node in nodes)
    {
        Console.WriteLine(node.Attribute("Code"));
    }   
    

提交回复
热议问题