Mega Code Archive

 
Categories / C# / XML
 

Gets an XmlAttributeCollection containing the attributes of this node

using System; using System.IO; using System.Xml; public class Sample {   public static void Main() {     XmlDocument doc = new XmlDocument();     doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-111111-57-5'>" +                 "<title>C#</title>" +                 "</book>");     XmlNode root = doc.FirstChild;     string ns = root.GetNamespaceOfPrefix("bk");     XmlNode attr = doc.CreateNode(XmlNodeType.Attribute, "genre", ns);     attr.Value = "novel";     root.Attributes.SetNamedItem(attr);     doc.Save(Console.Out);   } }