Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Convertir la valeur d’un Attribut

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

/*
  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 GetIntAttrib(XmlNode noeud, string attrib, int valDefaut)
    public static int GetIntAttrib(XmlNode noeud, string attrib, int valDefaut)
    {
      XmlAttribute xmlAttrib = noeud.Attributes[attrib];
      if (xmlAttrib == null)
        return valDefaut;
 
      string val = xmlAttrib.Value;
      if (val == null || val == string.Empty)
        return valDefaut;
 
      int returnVal = valDefaut;
      int.TryParse(val, out returnVal);
 
      return returnVal;
    }
    #endregion
  }
}

No comments yet.

Leave a Comment