StartElement Method
Writes the opening tag of an XML element.
Syntax
[VB.NET] Public Sub StartElement(ByVal Name As String, ByVal NamespaceURI As String)
[C#] public void StartElement(string name, string namespaceURI);
Remarks
Writes the opening tag of a new XML element. If an XML element is already opened, then this element is written as a child.
If Name is a local name without a prefix, the component will automatically introduce a new xmlns="NamespaceURI" attribute if necessary.
If Name is in the form prefix:local, then component will automatically introduce a new xmlns:prefix="NamespaceURI" as necessary.
When calling WriteElement or StartElement, if a NamespaceURI is not specified an empty namespace
will be defined for the element. If a namespace should be associated with the element, a NamespaceURI
value must be provided. When creating the XML, the component will determine if the namespace already exists
to avoid duplicate definitions of the same namespace. For example, to create this XML:
<book xmlns='urn:loc.gov:books' xmlns:isbn='urn:ISBN:0-395-36341-6'> <title>Cheaper by the Dozen</title> <isbn:number>1568491379</isbn:number> </book>Use the code:
xmlw.StartElement("book", "urn:loc.gov:books"); xmlw.WriteAttribute("xmlns:isbn", "", "urn:ISBN:0-395-36341-6"); xmlw.WriteElement("title", "urn:loc.gov:books", "Cheaper by the Dozen"); xmlw.WriteElement("isbn:number", "urn:ISBN:0-395-36341-6", "1568491379"); xmlw.Close();In the above example the "title" element uses the default namespace "urn:loc.gov:books" and the "number" element uses the "urn:ISBN:0-395-36341-6" namespace as defined for the "isbn" prefix. NOTE: This method has a corresponding asynchronous version (StartElementAsync) for use in the Xamarin environment.