XDeclaration Konstruktory

Definice

Inicializuje novou instanci XDeclaration třídy.

Přetížení

XDeclaration(XDeclaration)

Inicializuje novou instanci třídy z jiného XDeclaration objektuXDeclaration.

XDeclaration(String, String, String)

Inicializuje novou instanci XDeclaration třídy se zadaným stavem verze, kódování a samostatného stavu.

XDeclaration(XDeclaration)

Inicializuje novou instanci třídy z jiného XDeclaration objektuXDeclaration.

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)

Parametry

other
XDeclaration

Použitý XDeclaration k inicializaci tohoto XDeclaration objektu.

Poznámky

Tento konstruktor se primárně používá interně k vytvoření hloubkové kopie stromu XML.

Viz také

Platí pro

XDeclaration(String, String, String)

Inicializuje novou instanci XDeclaration třídy se zadaným stavem verze, kódování a samostatného stavu.

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)

Parametry

version
String

Verze XML, obvykle 1.0.

encoding
String

Kódování dokumentu XML.

standalone
String

Řetězec obsahující "ano" nebo "ne", který určuje, jestli je XML samostatný nebo vyžaduje překlad externích entit.

Příklady

Následující příklad vytvoří dokument, který obsahuje deklaraci.

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"))  

Tento příklad vytvoří následující výstup:

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

Viz také

Platí pro