XmlWriter.WriteStartElement Method (String, String)
[ 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, writes the specified start tag and associates it with the given namespace.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- localName
- Type: System.String
The local name of the element.
- ns
- Type: System.String
The namespace URI to associate with the element. If this namespace is already in scope and has an associated prefix, the writer automatically writes that prefix also.
| Exception | Condition |
|---|---|
| InvalidOperationException | The writer is closed. |
After calling this method you can either write attributes, or create content using WriteComment, WriteString, or WriteStartElement for child elements. You can close the element with either WriteEndElement or WriteFullEndElement. For example, the following C# code:
writer.WriteStartElement("item",null);
writer.WriteString("some text");
writer.WriteEndElement();
Generates the following output:
<item>some text</item>