XDeclaration Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the XDeclaration class.
Overloads
XDeclaration(XDeclaration) |
Initializes a new instance of the XDeclaration class from another XDeclaration object. |
XDeclaration(String, String, String) |
Initializes a new instance of the XDeclaration class with the specified version, encoding, and standalone status. |
XDeclaration(XDeclaration)
- Source:
- XDeclaration.cs
- Source:
- XDeclaration.cs
- Source:
- XDeclaration.cs
Initializes a new instance of the XDeclaration class from another XDeclaration object.
public:
XDeclaration(System::Xml::Linq::XDeclaration ^ other);
public XDeclaration (System.Xml.Linq.XDeclaration other);
new System.Xml.Linq.XDeclaration : System.Xml.Linq.XDeclaration -> System.Xml.Linq.XDeclaration
Public Sub New (other As XDeclaration)
Parameters
- other
- XDeclaration
The XDeclaration used to initialize this XDeclaration object.
Remarks
This constructor is primarily used internally to make a deep copy of an XML tree.
See also
Applies to
XDeclaration(String, String, String)
- Source:
- XDeclaration.cs
- Source:
- XDeclaration.cs
- Source:
- XDeclaration.cs
Initializes a new instance of the XDeclaration class with the specified version, encoding, and standalone status.
public:
XDeclaration(System::String ^ version, System::String ^ encoding, System::String ^ standalone);
public XDeclaration (string version, string encoding, string standalone);
public XDeclaration (string? version, string? encoding, string? standalone);
new System.Xml.Linq.XDeclaration : string * string * string -> System.Xml.Linq.XDeclaration
Public Sub New (version As String, encoding As String, standalone As String)
Parameters
- version
- String
The version of the XML, usually "1.0".
- encoding
- String
The encoding for the XML document.
- standalone
- 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.
XDocument doc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment("This is a comment"),
new XElement("Root", "content")
);
doc.Save("Root.xml");
Console.WriteLine(File.ReadAllText("Root.xml"));
Dim doc As XDocument = _
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!--This is a comment-->
<Root>content</Root>
doc.Save("Root.xml")
Console.WriteLine(File.ReadAllText("Root.xml"))
This example produces the following output:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!--This is a comment-->
<Root>content</Root>
See also
Applies to
.NET