XStreamingElement.ToString メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
必要に応じて書式設定を無効にして、このストリーミング要素の XML を返します。
オーバーロード
| 名前 | 説明 |
|---|---|
| ToString() |
このストリーミング要素の書式設定された (インデントされた) XML を返します。 |
| ToString(SaveOptions) |
必要に応じて書式設定を無効にして、このストリーミング要素の XML を返します。 |
注釈
XStreamingElementを使用するプログラムをデバッグする場合、オブジェクトの値を表示すると、そのToStringメソッドが呼び出されることに注意してください。 これにより、XML がシリアル化されます。 ストリーミング要素クエリのセマンティクスがストリーミング要素を 1 回しかストリーミングできない場合、デバッグ エクスペリエンスで望ましくない動作が発生する可能性があります。
ToString()
このストリーミング要素の書式設定された (インデントされた) XML を返します。
public:
override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
返品
インデントされた XML を含む String 。
例
次の例は、 ToStringの 2 つの使用方法を示しています。 最初の使用では、空白が保持されます。 2 つ目は、書式設定を使用して XStreamingElement をシリアル化します。
XElement srcTree = new XElement("Root",
new XElement("Child", 1),
new XElement("Child", 2),
new XElement("Child", 3),
new XElement("Child", 4),
new XElement("Child", 5)
);
XStreamingElement dstTree = new XStreamingElement("NewRoot",
from el in srcTree.Elements()
where (int)el == 3
select new XElement("DifferentChild", (int)el)
);
Console.WriteLine(dstTree.ToString(SaveOptions.DisableFormatting));
Console.WriteLine("------");
Console.WriteLine(dstTree.ToString());
Dim srcTree As XElement = _
<Root>
<Child>1</Child>
<Child>2</Child>
<Child>3</Child>
<Child>4</Child>
<Child>5</Child>
</Root>
Dim dstTree As XStreamingElement = New XStreamingElement("NewRoot", _
From el In srcTree.Elements() _
Where el.Value = 3 _
Select <DifferentChild><%= el.Value %></DifferentChild> _
)
Console.WriteLine(dstTree.ToString(SaveOptions.DisableFormatting))
Console.WriteLine("------")
Console.WriteLine(dstTree.ToString())
この例を実行すると、次の出力が生成されます。
<NewRoot><DifferentChild>3</DifferentChild></NewRoot>
------
<NewRoot>
<DifferentChild>3</DifferentChild>
</NewRoot>
注釈
XStreamingElementを使用するプログラムをデバッグする場合、オブジェクトの値を表示すると、そのToStringメソッドが呼び出されることに注意してください。 これにより、XML がシリアル化されます。 ストリーミング要素クエリのセマンティクスがストリーミング要素を 1 回しかストリーミングできない場合、デバッグ エクスペリエンスで望ましくない動作が発生する可能性があります。
こちらもご覧ください
適用対象
ToString(SaveOptions)
必要に応じて書式設定を無効にして、このストリーミング要素の XML を返します。
public:
System::String ^ ToString(System::Xml::Linq::SaveOptions options);
public string ToString(System.Xml.Linq.SaveOptions options);
override this.ToString : System.Xml.Linq.SaveOptions -> string
Public Function ToString (options As SaveOptions) As String
パラメーター
- options
- SaveOptions
書式設定の動作を指定する SaveOptions 。
返品
XML を含む String 。
例
次の例は、 ToStringの 2 つの使用方法を示しています。 最初の使用では、空白が保持されます。 2 つ目は、書式設定を使用して XStreamingElement をシリアル化します。
XElement srcTree = new XElement("Root",
new XElement("Child", 1),
new XElement("Child", 2),
new XElement("Child", 3),
new XElement("Child", 4),
new XElement("Child", 5)
);
XStreamingElement dstTree = new XStreamingElement("NewRoot",
from el in srcTree.Elements()
where (int)el == 3
select new XElement("DifferentChild", (int)el)
);
Console.WriteLine(dstTree.ToString(SaveOptions.DisableFormatting));
Console.WriteLine("------");
Console.WriteLine(dstTree.ToString());
Dim srcTree As XElement = _
<Root>
<Child>1</Child>
<Child>2</Child>
<Child>3</Child>
<Child>4</Child>
<Child>5</Child>
</Root>
Dim dstTree As XStreamingElement = New XStreamingElement("NewRoot", _
From el In srcTree.Elements() _
Where el.Value = 3 _
Select <DifferentChild><%= el.Value %></DifferentChild> _
)
Console.WriteLine(dstTree.ToString(SaveOptions.DisableFormatting))
Console.WriteLine("------")
Console.WriteLine(dstTree.ToString())
この例を実行すると、次の出力が生成されます。
<NewRoot><DifferentChild>3</DifferentChild></NewRoot>
------
<NewRoot>
<DifferentChild>3</DifferentChild>
</NewRoot>
注釈
XStreamingElementを使用するプログラムをデバッグする場合、オブジェクトの値を表示すると、そのToStringメソッドが呼び出されることに注意してください。 これにより、XML がシリアル化されます。 ストリーミング要素クエリのセマンティクスがストリーミング要素を 1 回しかストリーミングできない場合、デバッグ エクスペリエンスで望ましくない動作が発生する可能性があります。