XDocument.Save Method (XmlWriter)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
Parameters
- writer
- Type: System.Xml.XmlWriter
A XmlWriter that the XDocument will be written to.
The following example shows how to save an XDocument to an XmlWriter.
StringBuilder output = new StringBuilder(); StringBuilder sb = new StringBuilder(); XmlWriterSettings xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = true; xws.Indent = true; using (XmlWriter xw = XmlWriter.Create(sb, xws)) { XDocument doc = new XDocument( new XElement("Child", new XElement("GrandChild", "some content") ) ); doc.Save(xw); } output.Append(sb.ToString() + Environment.NewLine); OutputTextBlock.Text = output.ToString();
Show: