Get boolean value from Xml : Node Type « XML « C# / C Sharp






Get boolean value from Xml

  

using System;
using System.Xml;


public class XmlUtil
{

    #region LoadBool(ref bool val, XmlNode parent, string nodeName)
    public static void LoadBool(ref bool val, XmlNode parent, string nodeName)
    {
        try
        {
            XmlElement elem = parent[nodeName];
            if (elem != null)
                val = (elem.InnerText.Trim() == "1");
        }
        catch
        {
            val = false;
        }
    }
    #endregion

}

   
    
  








Related examples in the same category

1.XmlNodeType Text
2.XML reader: deal with various NodeTypeXML reader: deal with various NodeType
3.Read XML data from xml file: Node type, name
4.XML write: element, attribute, cddata, namespace and entity reference
5.Get int value from Xml