Add XML Attribute Node - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Add XML Attribute Node

Demo Code


using System.Globalization;
using System.Security.Cryptography;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Collections;
using System.Xml.XPath;
using System.Text;
using System.Xml;
using System.IO;//from   w ww .j  a v a 2 s. c o  m
using System;

public class Main{
        /// <summary>
      /// 
      /// </summary>
      /// <param name="Document"></param>
      /// <param name="Parent"></param>
      /// <param name="AttributeName"></param>
      /// <param name="AttributeValue"></param>
      /// <returns></returns>
      public static XmlNode AddAttributeNode(XmlDocument Document, XmlNode Parent, string AttributeName, object AttributeValue)
      {
         XmlAttribute attr = Document.CreateAttribute(AttributeName);
         attr.Value = AttributeValue.ToString();
         Parent.Attributes.Append(attr);
         return attr;
      }
}

Related Tutorials