Get attribute or return default value

image_pdfimage_print
   
 

//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 GetAttrib(XmlNode node, string attrib, string defVal)
    public static string GetAttrib(XmlNode node, string attrib, string defVal)
    {
      XmlAttribute xmlAttrib = node.Attributes[attrib];
      if (xmlAttrib == null)
        return defVal;

      string val = xmlAttrib.Value;
      return (val == null) ? defVal : val;
    }
    #endregion
  }
}

   
     


This entry was posted in XML-RPC. Bookmark the permalink.