CSharp examples for System.Xml:XML Attribute
Get an optional attribute value from an XmlNode.
using System.Xml; using System.Collections.Generic; using System;/*from w ww .ja v a 2 s . co m*/ public class Main{ /// <summary> /// Get an optional attribute value from an XmlNode. /// </summary> /// <param name="node">The XmlNode to look in.</param> /// <param name="attrName">The attribute to find.</param> /// <returns>The value of the attribute, or null, if not found.</returns> public static string GetAttributeValue(XmlNode node, string attrName) { return GetOptionalAttributeValue(node, attrName); } /// <summary> /// Deprecated: use GetOptionalAttributeValue instead. /// </summary> /// <param name="node"></param> /// <param name="attrName"></param> /// <param name="defaultValue"></param> /// <returns></returns> public static string GetAttributeValue(XmlNode node, string attrName, string defaultValue) { return GetOptionalAttributeValue(node, attrName, defaultValue); } }