WriteStartElement Method (String, String)
Collapse the table of content
Expand the table of content

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.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public void WriteStartElement(
	string localName,
	string ns
)

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.

ExceptionCondition
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>

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft