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

XmlDataDocument.CreateElement Method (String, String, String)

Creates an element with the specified Prefix, LocalName, and NamespaceURI.

Namespace: System.Xml
Assembly: System.Data (in

public override XmlElement CreateElement (
	string prefix,
	string localName,
	string namespaceURI
public XmlElement CreateElement (
	String prefix, 
	String localName, 
	String namespaceURI
public override function CreateElement (
	prefix : String, 
	localName : String, 
	namespaceURI : String
) : XmlElement
Not applicable.



The prefix of the new element If String.Empty or a null reference (Nothing in Visual Basic), there is no prefix.


The local name of the new element.


The namespace Uniform Resource Identifier (URI) of the new element. If String.Empty or a null reference (Nothing in Visual Basic), there is no namespaceURI.

Return Value

A new XmlElement.

Note to Inheritors If you overload this function, it cannot be used for extensibility. Instead, you can return an element created by the base class, in this case, XmlDataDocument. See the following example.

 class MyXmlDataDocument : XmlDataDocument {
  public override XmlElement CreateElement(string prefix, string localName, string nsURI) {
    //Ensure we are returning the base class implementation of element.
    XmlElement e = base.CreateElement(prefix, localName, nsURI);
    //Add additional code here.
    return e;    //Return the element created by XmlDataDocument.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

© 2015 Microsoft