Writes an attribute with the specified local name, namespace URI, and value.
using System;
using System.IO;
using System.Xml;
public class Sample {
public static void Main() {
XmlWriter writer = null;
writer = XmlWriter.Create("sampledata.xml");
writer.WriteStartElement("book");
writer.WriteAttributeString("xmlns","bk", null,"urn:book");
writer.WriteAttributeString("ISBN", "urn:book", "1-111-111");
writer.WriteElementString("price", "1.5");
writer.WriteEndElement();
writer.Flush();
writer.Close();
}
}
Related examples in the same category