Traiter la valeur d’un attribut

Author:

Utilisation,de,la,classe,'XmlTextReader',pour,lire,un,document,XML
{filelink=16403}

/*
 Microsoft Public License (Ms-PL)
 http://dbmlmanager.codeplex.com/license
*/

#region using
using System;
using System.Xml;
#endregion

namespace DbmlManager.Lib.Utility
{
  #region Class Docs
  ///

  /// Summary description for XmlUtil.
  /// 

  #endregion

  public class XmlUtil
  {
    #region GetBoolAttrib(XmlNode noeud, string attrib, bool valDefaut)
    public static bool GetBoolAttrib(XmlNode noeud, string attrib, bool valDefaut)
    {
      XmlAttribute xmlAttrib = noeud.Attributes[attrib];
      if (xmlAttrib == null)
        return valDefaut;

      string val = xmlAttrib.Value;
      if (val == null || val == string.Empty)
        return valDefaut;

      bool returnVal = (val == "1" || val.ToLower() == "true");

      return returnVal;
    }
    #endregion
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *