Get Attribute Value from XmlNode - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get Attribute Value from XmlNode

Demo Code


using System.Xml;
using System.Text;
using System.Collections.Generic;
using System;// w  w  w .  j  av  a 2 s. com

public class Main{
        #region internal static string GetAttributeValue(XmlNode node, string attributeName)
      internal static string GetAttributeValue(XmlNode node, string attributeName)
      {
         string result = null;

         if (node != null)
         {
            XmlAttribute attribute = node.Attributes[attributeName];
            if (attribute != null)
               result = attribute.Value;
         }

         return result;
      }
}

Related Tutorials