Search notes:

System.Xml.XmlDocument - Save()

The Save() method of a System.Xml.XmlDocument object formats an XML document and stores it.

Formatting the XML document

Saving the formatted document to a file

The following simple PowerShell example tries to demonstrate how Save() formats an XML document:
[xml] $doc = '<root><elem>foo</elem><elem>bar</elem><elem>baz</elem></root>'
$doc.Save( "$env:temp/formatted.xml")
get-content $env:temp/formatted.xml
The stored document is:
<root>
  <elem>foo</elem>
  <elem>bar</elem>
  <elem>baz</elem>
</root>

Formatting a document to the console

One of the Save() methods is overloaded to accept a System.IO.TextWriter class.
A class that inherits from this class is provided by the property Out of System.Console.
Thus, an XML document can be rendered to the console in PowerShell like so:
PS C:\> $doc.Save([Console]::Out)

Index