Get XML Attribute Value For Property - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get XML Attribute Value For Property

Demo Code


using System.Xml;
using System.Runtime.Remoting.Messaging;
using System.Linq;
using System;//from ww  w .  j a  v a2  s .  c o  m

public class Main{
        public static string GetAttributeValueForProperty(this XmlElement element, string propertyName)
    {
      return element.HasAttributeForProperty(propertyName)
        ? element.GetAttribute(propertyName.ToCamelCase())
        : String.Empty;
    }
        public static bool HasAttributeForProperty(this XmlElement element, string propertyName)
    {
      return element.HasAttribute(propertyName.ToCamelCase());
    }
}

Related Tutorials