XDeclaration Constructor (String, String, String)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Initializes a new instance of the XDeclaration class with the specified version, encoding, and standalone status.

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

Syntax

'Declaration
Public Sub New ( _
    version As String, _
    encoding As String, _
    standalone As String _
)
public XDeclaration(
    string version,
    string encoding,
    string standalone
)

Parameters

  • version
    Type: System.String
    The version of the XML, usually "1.0".
  • encoding
    Type: System.String
    The encoding for the XML document.
  • standalone
    Type: System.String
    A string containing "yes" or "no" that specifies whether the XML is standalone or requires external entities to be resolved.

Examples

The following example creates a document that contains a declaration.

            Dim doc As XDocument = _
            <?xml version="1.0" encoding="utf-8" standalone="yes"?>
            <!--This is a comment-->
            <Root>content</Root>

XDocument doc = new XDocument(
    new XDeclaration("1.0", "utf-8", "yes"),
    new XComment("This is a comment"),
    new XElement("Root", "content")
);

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.