Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Traiter la valeur d’un attribut

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>
  /// Summary description for XmlUtil.
  /// </summary>
 
  #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
  }
}

No comments yet.

Leave a Comment