Get Item Value from XmlNode - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Get Item Value from XmlNode

Demo Code

// All rights reserved.
using System.Diagnostics;
using System.Collections.Specialized;
using System.Xml;
using System.Data;
using System;/*from  ww  w  .ja v a  2  s.co  m*/

public class Main{
        // Get UInt32 value from a node.
        public static bool GetItemValue(XmlNode node, string itemName, ref UInt32 value)
        {
            bool success = false;
            if (node != null && node[itemName] != null)
            {
                value = UInt32.Parse(node[itemName].InnerText);
                success = true;
            }
            return success;
        }
        // Get Int32 value from a node.
        public static bool GetItemValue(XmlNode node, string itemName, ref Int32 value)
        {
            bool success = false;
            if (node != null && node[itemName] != null)
            {
                value = Int32.Parse(node[itemName].InnerText);
                success = true;
            }
            return success;
        }
        #endregion

        #region GetItemValue(node, name, value)
        public static bool GetItemValue(XmlNode node, string itemName, ref string value)
        {
            bool success = false;
            if (node != null && node[itemName] != null)
            {
                value = node[itemName].InnerText;
                success = true;
            }
            return success;
        }
}

Related Tutorials