CSharp examples for System.Xml:XML Node
Get UInt32 value from XML node.
using System.Diagnostics; using System.Collections.Specialized; using System.Xml; using System.Data; using System;// w w w . j a va 2 s . c o m public class Main{ /// <summary> /// Get UInt32 value from a node. /// </summary> /// <param name="node"></param> /// <param name="itemName"></param> /// <param name="value"></param> /// <returns></returns> 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; } /// <summary> /// Get Int32 value from a node. /// </summary> /// <param name="node"></param> /// <param name="itemName"></param> /// <param name="value"></param> /// <returns></returns> 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) /// <summary> /// Get item value /// </summary> /// <param name="node"></param> /// <param name="itemName"></param> /// <param name="value"></param> /// <returns></returns> 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; } }