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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1759398187, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/dot-net/namespaces-classes/System/Xml/XmlDocument/Save/index(62): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78