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
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)