Add the specified XML attribute. - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Add the specified XML attribute.

Demo Code

// Licensed under the Apache License, Version 2.0 (the "License");
using System.Xml;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from   ww  w .  j a va  2s.  c  o m

public class Main{
        /// <summary>
        /// Add the specified attribute.
        /// </summary>
        /// <param name="e">The node to add the attribute to.</param>
        /// <param name="name">The name of the attribute.</param>
        /// <param name="value_ren">The value of the attribute.</param>
        public static void AddAttribute(XmlNode e, String name,
                 String value_ren)
        {
            XmlAttribute attr = e.OwnerDocument.CreateAttribute(name);
            attr.Value = value;
            e.Attributes.SetNamedItem(attr);
        }
}

Related Tutorials