Set Attribute Value in XmlNode - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Set Attribute Value in XmlNode

Demo Code


using System.Xml;
using System.Text;
using System.Collections.Generic;
using System;// w  ww  .jav  a  2  s  .  c  o m

public class Main{
        #endregion

      #region private static void SetAttributeValue(XmlNode node, string attributeName, string attributeValue)
      internal static void SetAttributeValue(XmlNode node, string attributeName, string attributeValue)
      {
         XmlAttribute attribute = node.Attributes[attributeName];
         if (attribute == null)
            attribute = node.Attributes.Append(node.OwnerDocument.CreateAttribute(attributeName));
         attribute.Value = attributeValue;
      }
}

Related Tutorials