Select Single XML Attribute String - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Select Single XML Attribute String

Demo Code


using System.Xml;
using System;/*  w w w  .ja  v a2s.c  om*/

public class Main{
        public static string SelectSingleAttributeString(XmlNode node, string name, string defaultValue = null)
    {
        if (node?.Attributes == null)
        {
            return defaultValue;
        }

        workAttr = node.Attributes[name];
        return workAttr != null ? workAttr.Value : defaultValue;
    }
}

Related Tutorials