XML commands
Extensible Markup Language (XML) is a plain text format that is used to store structured data. XML is written to be both human and machine readable.
PowerShell includes the Select-Xml
and ConvertTo-Xml
commands to work with XML content.
Before exploring the commands, it is useful to understand the basic structure of an XML document.
About XML
XML documents often begin with a declaration, as shown here:
<?xml version="1.0" encoding="utf-8"?>
This declaration has three possible attributes. The version attribute is mandatory when a declaration is included:
- version: The XML version,
1.0
or1.1
. - encoding: The file encoding, most frequently
utf-8
orutf-16
. - standalone: Whether the XML file uses an internal or external Document Type Definition (DTD); permissible values are yes or no.
The use of the standalone
directive with DTD is beyond the scope of this chapter.
Elements and attributes
XML is similar in appearance to HTML. Elements begin...