Line 2 in the script below generates -
“Cannot convert the value“ System.Object [] ”to the input“ System.Xml.XmlDocument. ”Error:“ '→', the hex value 0x1A, is an invalid character. Line 39, position 23. "
In line: 1 char: 8 + [xml] $ x <<= Get-Content 4517.xml + CategoryInfo: MetadataError: (:) [], ArgumentTransformationMetadataException + FullyQualifiedErrorId: RuntimeException "
What exception should be indicated on line 4 (script) in order to catch the above error?
try { [xml]$xml = Get-Content $file # line 2 } catch [?] { # line 4 echo "XML parse error!" # handle the parse error differently } catch { echo $error # some general error }
Thanks for watching (and responding)
Adrian
source share