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.

XElement.Save Method (XmlWriter)

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Serialize this element to an XmlWriter.

Namespace:  System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

public void Save(
	XmlWriter writer
)

Parameters

writer
Type: System.Xml.XmlWriter
A XmlWriter that the XElement will be written to.

The following example shows how to save an XElement to an XmlWriter.


StringBuilder output = new StringBuilder();
StringBuilder sb = new StringBuilder();
XmlWriterSettings xws = new XmlWriterSettings();
xws.OmitXmlDeclaration = true;
using (XmlWriter xw = XmlWriter.Create(sb, xws))
{
    XElement root = new XElement("Root",
        new XElement("Child", "child content")
    );
    root.Save(xw);
}
output.Append(sb.ToString() + Environment.NewLine);

OutputTextBlock.Text = output.ToString();


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show: