Writes the start of an attribute.
[Visual Basic] Overrides Public Sub WriteStartAttribute( _ ByVal name As String, _ ByVal ns As String _ ) [C#] public override void WriteStartAttribute( string name, string ns ); [C++] public: override void WriteStartAttribute( String* name, String* ns ); [JScript] public override function WriteStartAttribute( name : String, ns : String );
Exception Type | Condition |
---|---|
ArgumentException | The attribute is named "xmlns:xml" and Namespaces is true. This is invalid according to the namespace spec. |
This is a more advanced version of WriteAttribute that allows you to write an attribute value using multiple write methods, such as WriteString, WriteChar, WriteInt, and so on. For example:
writer.WriteStartElement("item"); writer.WriteStartAttribute("ids",null); writer.WriteInt(12); writer.WriteInt(25); writer.WriteInt(17); writer.WriteEndAttribute(); writer.WriteInt(122); writer.WriteEndElement();
which produces the following output:
<item id="12 25 17">122</item>
Notice that the WriteEndAttribute makes the last call to WriteInt(122) generate element content instead of attribute content.
XmlTextWriter Class | XmlTextWriter Members | System.NewXml Namespace