XML file structure
When PowerShell interacts with XML, it leverages an XML reading engine known as an XML parser. Much like how PowerShell parses PS1 scripts, the XML parser will read line by line and interpret the contents of the XML file. When the PowerShell XML parser reads the file, it has all of the encoding logic built in, so that it can read the different parts of the XML file. After the XML parser reads the file, it will make the contents available for use within your PowerShell scripts.
For an XML parser to know the file is an XML file, you have to make an XML declaration at the beginning of the file. The following graphic represents a properly created XML declaration:
The XML declaration is a mandatory line at the very beginning of the XML document itself. There are several parts of the XML declaration that are mandatory. The declaration tag of XML starts by leveraging the code <?xml
and is required to tell the XML parser that the version and encoding items may be following...