XDeclaration XDeclaration XDeclaration XDeclaration Constructors

Definition

Overloads

XDeclaration(XDeclaration) XDeclaration(XDeclaration) XDeclaration(XDeclaration) XDeclaration(XDeclaration)

Initializes a new instance of the XDeclaration class from another XDeclaration object.

XDeclaration(String, String, String) XDeclaration(String, String, String) XDeclaration(String, String, String) XDeclaration(String, String, String)

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

XDeclaration(XDeclaration) XDeclaration(XDeclaration) XDeclaration(XDeclaration) XDeclaration(XDeclaration)

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 XDeclaration XDeclaration 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

XDeclaration(String, String, String) XDeclaration(String, String, String) XDeclaration(String, String, String) XDeclaration(String, String, String)

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);
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 String String String

The version of the XML, usually "1.0".

encoding
String String String String

The encoding for the XML document.

standalone
String String String 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