Get XML Float Attribute - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Get XML Float Attribute

Demo Code


using System.Xml;

public class Main{
        public static float GetFloatAttribute(this XmlNode node, string key, float defaultValue)
        {//from  ww w .  j  av a  2  s. co m
            XmlAttributeCollection attributes = node.Attributes;
            float val = defaultValue;

            if (attributes[key] != null
                && !string.IsNullOrEmpty(attributes[key].Value))
            {
                float.TryParse(attributes[key].Value, out val);
            }
            return val;
        }
}

Related Tutorials