XDeclaration コンストラクター

定義

XDeclaration クラスの新しいインスタンスを初期化します。

オーバーロード

XDeclaration(XDeclaration)

他の XDeclaration オブジェクトから XDeclaration クラスの新しいインスタンスを初期化します。

XDeclaration(String, String, String)

バージョン、エンコーディング、およびスタンドアロン ステータスを指定して、XDeclaration クラスの新しいインスタンスを初期化します。

XDeclaration(XDeclaration)

Source:
XDeclaration.cs
Source:
XDeclaration.cs
Source:
XDeclaration.cs

他の XDeclaration オブジェクトから XDeclaration クラスの新しいインスタンスを初期化します。

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)

パラメーター

other
XDeclaration

この XDeclaration オブジェクトを初期化するために使用する XDeclaration

注釈

このコンストラクターは、主に XML ツリーのディープ コピーを作成するために内部的に使用されます。

こちらもご覧ください

適用対象

XDeclaration(String, String, String)

Source:
XDeclaration.cs
Source:
XDeclaration.cs
Source:
XDeclaration.cs

バージョン、エンコーディング、およびスタンドアロン ステータスを指定して、XDeclaration クラスの新しいインスタンスを初期化します。

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)

パラメーター

version
String

XML のバージョン (通常は "1.0")。

encoding
String

XML ドキュメントのエンコーディング。

standalone
String

XML がスタンドアロンか、または外部エンティティの解決が必要かを指定する、"yes" または "no" が含まれた文字列。

次の例では、 宣言を含むドキュメントを作成します。

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

この例を実行すると、次の出力が生成されます。

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

こちらもご覧ください

適用対象