Trying to run a powershell script, but I am being greeted with the error message:
Exception calling "Load" with "1" argument(s): "'=' is an unexpected token. The expected token is ';'. Line [line-number], position [position]."
From reviewing the error message and line number, the offending code line is:
# Declare XML Object $xmlConfig = New-Object -TypeName XML $configFile = 'websitelist.config' # Load Configuration File $xmlConfig.Load($configFile)
To fix, I will suggest the following:
Review XML File
Review XML file using an XML Editor. There are plenty of free ones. I am currently using XML Copy Editor. It is available from http://xml-copy-editor.sourceforge.net/
Check For Well-Formedness
We get an error when we tested our XML Config file.
Error at line 54, Column 151 : not well-formed (invalid token)
The problematic element in the XML file contains an HTTP/Web URL.
To fix, I need to Encode it:
There are plenty of free XML Encoders on the .Net. List of good ones includes:
- Free Formatter
There are plenty of options on this web site:
We will choose “String Escaper & Utilities \ XML Escape”.
We will enter the “unescaped” URL, choose the “Escape” option, and get back an escaped XML.
Take that Escaped URL, to our editor and we are good.
Unfortunately, this is what happens when one finds himself like “Johnny Football” and one only does this things on the weekend.