Get Boolean from XmlNode - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Get Boolean from XmlNode

Demo Code


using System.Globalization;
using System.Security.Cryptography;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Collections;
using System.Xml.XPath;
using System.Text;
using System.Xml;
using System.IO;/*  w  w w.  j  a v a  2 s .  c o m*/
using System;

public class Main{
        /// <summary>
      /// 
      /// </summary>
      /// <param name="Node"></param>
      /// <param name="NodeName"></param>
      /// <returns></returns>
      public static bool GetBoolean(XmlNode Node, string NodeName)
      {
         string val = GetString(Node, NodeName).Trim().ToUpper(CultureInfo.InvariantCulture);
         return (val == "1" || val == "YES");
      }
        /// <summary>
      /// 
      /// </summary>
      /// <param name="Navigator"></param>
      /// <param name="XPath"></param>
      /// <returns></returns>
      public static bool GetBoolean(XPathNavigator Navigator, XPathExpression XPath)
      {
         string val = GetString(Navigator, XPath).Trim().ToUpper(CultureInfo.InvariantCulture);
         return (val == "1" || val == "YES" || val == "TRUE");
      }
        /// <summary>
      /// 
      /// </summary>
      /// <param name="Navigator"></param>
      /// <param name="NodeName"></param>
      /// <returns></returns>
      public static bool GetBoolean(XPathNavigator Navigator, string NodeName)
      {
         string val = GetString(Navigator, NodeName).Trim().ToUpper(CultureInfo.InvariantCulture);
         return (val == "1" || val == "YES" || val == "TRUE");
      }
}

Related Tutorials