XmlWriter.WriteEndAttribute Method
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
When overridden in a derived class, closes the previous WriteStartAttribute call.
Assembly: System.Xml (in System.Xml.dll)
If you call WriteStartAttribute, you can close the attribute with this method.
You can also close the attribute by calling WriteStartAttribute again, calling WriteAttributeString, or calling WriteEndElement.
StringBuilder output = new StringBuilder(); Double price = 9.95; DateTime date = new DateTime(2004, 5, 20); using (XmlWriter writer = XmlWriter.Create(output)) { writer.WriteStartElement("book"); writer.WriteStartAttribute("pub-date"); writer.WriteValue(date); writer.WriteEndAttribute(); writer.WriteStartElement("price"); writer.WriteValue(price); writer.WriteEndElement(); writer.WriteEndElement(); writer.Flush(); } OutputTextBlock.Text = output.ToString();
Show:
Note: