XDeclaration コンストラクター

定義

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

オーバーロード

名前 説明
XDeclaration(XDeclaration)

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

XDeclaration(String, String, String)

指定したバージョン、エンコード、およびスタンドアロンの状態を使用して、 XDeclaration クラスの新しいインスタンスを初期化します。

XDeclaration(XDeclaration)

ソース:
XDeclaration.cs
ソース:
XDeclaration.cs
ソース:
XDeclaration.cs
ソース:
XDeclaration.cs
ソース:
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)

ソース:
XDeclaration.cs
ソース:
XDeclaration.cs
ソース:
XDeclaration.cs
ソース:
XDeclaration.cs
ソース:
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>

こちらもご覧ください

適用対象