Nick Dewitt Nick Dewitt - 5 months ago 31 Question

Importing XML with 'µ' symbol into excel

I am trying to import an XML file into excel using Data -> Other Sources -> From XML Data import. When the file contains a 'µ' symbol, it gives the following error:

Invalid file reference. The path to the file is invalid, or one or
more of the referenced schemas could not be found.

The XML looks like this:

<FileName>Data\7.5 µg_mL Sample.pdf</FileName>

If i remove the microgram symbol, it works and Excel imports the data.

I am generating the XML file in .net using
, and if I run the XML through a validator, it returns no errors. It doesn't seem to matter if I put the XML declaration at the top of the file and declare it as UTF-8 or 16 either.

Any pointers welcome, i would ideally like to check for any characters that might cause this problem as i am guessing there are more than just the microgram symbol.

I am passing the XML string to a function that swaps out a custom xml file, i don't seem to have the option to change the file format here..

'Uses Ionic.Zip.ZipFile
Using zip As ZipFile = ZipFile.Read(fileDest)
zip.AddEntry(xmlPath, customXml)
End Using


Per the docs for the overload of AddEntry you are using:

The content for the entry is encoded using the default text encoding for the machine

You want this to be UTF-8, so you can use the overload that allows you to specify the encoding:

zip.AddEntry(xmlPath, customXml, Encoding.UTF8);