Parse Boolean from XmlNode - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Parse Boolean from XmlNode

Demo Code


using System.Xml;
using System;/*from w  w w .  j  ava2 s  .  co  m*/

public class Main{
        public static bool ParseBoolean(XmlNode n, string nodeName)
        {
            bool result = false;

            string temp = "0";
            if (n != null)
            {
                if (n.SelectSingleNode(nodeName) != null)
                {
                    temp = n.SelectSingleNode(nodeName).InnerText;
                }
            }

            if (temp == "1")
            {
                result = true;
            }

            return result;
        }
}

Related Tutorials