Get Node Array By XML Name Attribute - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get Node Array By XML Name Attribute

Demo Code


using System.Xml.Linq;
using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w  ww .j  ava 2 s.co  m*/

public class Main{
        public static IEnumerable<XElement> GetNodeArrayByNameAttribute(XElement item, string NodeName, string AttrName, string AttrValue)
        {
            var res = (from e in item.Elements(NodeName)
                       where e.Attribute(AttrName).Value == AttrValue
                       select e);
            return res;
        }
}

Related Tutorials