Determines if the given XML attribute exists - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Determines if the given XML attribute exists

Demo Code

/*//from  w  w  w  .j a v a 2 s .c o  m
  Copyright (c) 2011, Raincity Games LLC
  Licensed under the MIT license: http://www.opensource.org/licenses/mit_license.php
*/
using System.Xml;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class Main{
        /// <summary>
        /// Determines if the given attribute exists
        /// </summary>
        static public bool AttributeExists(XmlNode xmlNode, string attributeName)
        {
            XmlAttribute attribute = xmlNode.Attributes[attributeName];
            if (attribute == null)
                return false;
            return true;
        }
}

Related Tutorials