I have issues writing a XML parser/merger, there is this XML that uses UTF8-BOM encoding and I get an error while using XElement.Parse. However if I convert that file to UTF8 without BOM it solves the issue.
The error is "- {"Data at the root level is invalid. Line 1, position 1."}".
This XML is downloaded from a SOAP API to a Byte stream and then converted to a string like this:
Dim sourceFile_as_Byte = SOAPAPI.Download 'I download the file using a SOAP API method.
Dim ByteEncoder As System.Text.Encoding = System.Text.Encoding.UTF8
SourceFile_as_string = ByteEncoder.GetString(SourceFile_as_Byte)
Dim XMLdoc As XElement
XMLdoc = XElement.Parse(SourceFile_as_string)
I've found other solutions like using XElement.Load which works regardless (seems .Load manages the encoding?) but due to the nature of the solution I need to use the Parse method so that's why I'm trying to convert that string and remove the BOM.
Thanks