Mono Class Library: System.Xml.XmlWriter Overview | Members

System.Xml.XmlWriter.WriteStartElement Method

Writes a start element with the specified name, and associates it with the given namespace and prefix. [Edit]

public abstract void WriteStartElement (string prefix, string localName, string ns)

Parameters

prefix
A string specifying the namespace prefix of the element. [Edit]
localName
A string specifying the local name of the element. [Edit]
ns
A string specifying the namespace URI to associate with the element. [Edit]

Exceptions

TypeReason
InvalidOperationExceptionThe XmlWriter.WriteState is WriteState.Closed. [Edit]

Remarks

Operation

This method writes a start element and name, and associates it with a namespace and prefix. If the namespace is already in scope and has an associated prefix, that prefix is automatically written also.

If any of the input parameters are null or string.Empty, the start element is written with that parameter missing.

Note to Inheritors
When overriding this method, also override the XmlWriter.WriteEndElement, XmlWriter.WriteString(string), and XmlWriter.WriteRaw(Char[], int, int) methods so they close any open start element.

Usage
Use this method to write a specified start element and name, and associate it with a given namespace and prefix. Write any attributes using the XmlWriter.WriteStartAttribute(string, string), XmlWriter.WriteString(string), and XmlWriter.WriteEndAttribute methods, then close the element using the XmlWriter.WriteEndElement method.

[Edit]

Example

See XmlTextWriter.WriteStartElement(string, string, string) for an example demonstrating this method.

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0