Get the encoding from XML file

Is there any idea on how to get the encoding of an XML file (usually in the first line)? Using an import mapping doesn't work because the first line e.g. <?xml version="1.0" encoding="utf-8"?> is not applicable for a mapping. I receive the XML files as FileDocuments.   I want to know the encoding beforehand for using String to file java action, which asks for an encoding. So I can't use String to file either because to get the encoding from this action I need to apply the correct encoding first. 
2 answers

Hello Kurt,


Is there a way you know which different types of encoding you receive?

So do you know if it are two types or are it more than 10 types?

If it is just two you can maybe do a search on the string with contains() and then searching for encoding=UTF-8, etc etc.

I think the key is to understand the different files you can get, the structure of the files, and how to find the right encoding within every structure generically everytime.

Another option is to create a custom action that can give you back the encoding, i see some different solutions on that on the internet.


Hope this helps,


Good luck!


So far a custom Java action seems to be the only way. I would've hoped a Mendix solution would've been a possibility.