Get Attribute from XML - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get Attribute from XML

Demo Code


using System.Xml;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/* w  ww.jav a 2  s  . c om*/

public class Main{
        public static string GetAttr(this XmlElement element, string attrName)
        {
            XmlAttribute attr = element.Attributes[attrName];
            return (attr != null) ? attr.Value : string.Empty;
        }
}

Related Tutorials