Add the specified attribute to XML. - CSharp System.Xml

CSharp examples for System.Xml:XML Attribute

Description

Add the specified attribute to XML.

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 w  ww .ja  v  a 2s  . com*/

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