Reads a true false value from XmlNode - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Reads a true false value from XmlNode

Demo Code


using System.Xml;
using System.Text;
using System.Collections.Generic;
using System;/*from  w  w  w .j  a va 2s  .  co m*/

public class Main{
        /// <summary>
    /// Reads a true/false value
    /// </summary>
    /// <param name="xNode"></param>
    /// <param name="attributeName"></param>
    /// <param name="defaultValue"></param>
    /// <returns></returns>
    internal static string ReadTextAttribute(XmlNode xNode, string attributeName, string defaultValue = "")
    {
        var attribute = xNode.Attributes[attributeName];
        if (attribute == null)
        {
            return defaultValue;
        }

        return attribute.Value;
    }
}

Related Tutorials