Load String from xml element : DOM « XML « C# / C Sharp






Load String from xml element

   
//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 LoadString(ref string val, XmlNode parent, string nodeName)
    public static void LoadString(ref string val, XmlNode parent, string nodeName)
    {
      try
      {
        XmlElement elem = parent[nodeName];
        if (elem != null)
          val = elem.InnerText.Trim();
      }
      catch
      {
        val = string.Empty;
      }
    }
    #endregion

  }
}

   
    
    
  








Related examples in the same category

1.DOM feature check
2.Create Xml Document, Node
3.Load boolean value from xml element
4.Get integer value from xml element
5.Get attribute from XmlNode
6.Set Xml Node Value
7.Get Value String from Xml
8.Get InnerXml without changing the spacing
9.Get Inner Xml
10.Add Xml Element
11.Returns the InnerText value from a node or string.Empty if the node is null.
12.Sets the inner text in a node. If the node doesn't exist, it creates a new one and adds the text to it.