This is not a big issue and I have "resolved" it by defining it as a variable. But I am curious as to why it is doing this - I am not sure if it is a Kixtart issue or a parsing issue with XML syntax?

 Code:
      $XML = CreateObject("Microsoft.XMLDOM")
      $XML.Load($Filename)


When you run $xml.Load($FileName) it always outputs code -1 which suggests that it is either having a problem opening the file (which is not the case as the rest of the code works as expected) or there is a parsing error reading the file.

 Code:
      $XML = CreateObject("Microsoft.XMLDOM")
      $ = $XML.Load($Filename)


This works perfectly, or rather it is suppressing the output code. Normally we want to use $x = to suppress outputs like 0 for the addprinterconnection as we don't need to see it was successful. But in this case, there is obviously an error so it's outputting -1. I don't tend to use @error much.

I have uploaded the xml file to several xml validators and they do find syntax issues, but as I far as I can tell, the xml syntax is correct according to Microsoft - online and using a file created by Microsoft itself. The syntax issues may be more to do with a different library versions of xml or perhaps the xml online is more for html xml type files?

The xml files that I am working with are the Windows Libraries - which can be found in this folder - C:\Users\Username\AppData\Roaming\Microsoft\Windows\Libraries.

I am using Kixtart to load the custom Libraries that I have copied across to the Libraries folder to input the url relevant for that library. Works perfectly apart from this strange -1 output. As it does work, I see no value spending a lot of time on it, but I am curious as to why it's happening and whether this is a kixtart or xml issue.