Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

XNode.ToString Method

Returns the indented XML for this node.

Namespace:  System.Xml.Linq
Assemblies:   System.Xml.XDocument (in System.Xml.XDocument.dll)
  System.Xml.Linq (in System.Xml.Linq.dll)

public override string ToString()

Return Value

Type: System.String
A String containing the indented XML.

The following example uses this method to retrieve indented XML.

XElement xmlTree = new XElement("Root",
    new XElement("Child1", 1)
);
Console.WriteLine(xmlTree);

This example produces the following output:

<Root>
  <Child1>1</Child1>
</Root>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft