I'm trying to import an xml file into vb.net XmlDocument but am getting the error:
'.', hexadecimal value 0x00, is an invalid character. Line 94, position 1.
I'm wondering if there is a way to replace the hex character 0x00
The following are lines 92,93,94 the file ends on line 94
92 | </request>
93 |</rpc> <!-- XML Finishes here -->
94 |
Thanks for any help.
EDIT: adding code used to get the file.
Dim fs As FileStream = File.Open(FileName, FileMode.Open, FileAccess.Read)
Dim buffer(fs.Length) As Byte
fs.Read(buffer, 0, fs.Length)
Dim xmlString As String = System.Text.UTF8Encoding.UTF8.GetString(buffer)
fs.close()
Doc.LoadXml(xmlString.Trim)
I am using System.Text.UTF8Encoding.UTF8.GetString(buffer) because the file encoding is not always UTF-8. Unfortunatly I don't have controll over the xml file as we are receiving it from an external source who wont change the way the file is generated as it is used by others.
What I want to do is basically get the file into the string then either chop off the end of it from the last > and then append my own > or just replace the HEX character with an empty string.