Hi, I posted the same question on the runrev list and got a solution from Mark:
Code: Select all
on mouseUp
local tInitialXML, tXmlId
put "<?xml version='1.0' encoding='UTF-8'?><identity><name></name></identity>" into tInitialXML
put revXMLCreateTree(tInitialXML,false,true,false) into tXmlId
revXMLPutIntoNode tXmlId, "/identity/name", textEncode("Äiti", "utf-8")
put revXMLText(tXmlId) into URL ("binfile:"&specialFolderPath("desktop")&slash&"myFile.xml")
end mouseUp
Mark Waddingham wrote furthermore as explanation:
"You have to create the XML tree with an initial `<?xml` line so that libxml2 knows what encoding you want - utf-8 will give what the use-cases here have requested. Then, you have to textEncode any text you use as utf-8 before passing it to the command/function (usually just content, but also attributes, element names or attribute values - if any may contain non-ascii text). Finally, revXMLText will return an already encoded bit of binary data you can put into a file - hence binfile."
I tested it and it works exactly as intended. Thanks Mark. I just thought to post it here as well for those who missed it on the runrev list.
If I understood it correctly my mistake was that when initialising the xml tree I did not explicitley tell that I want the xml tree to use utf-8 encoding.
Best
Oliver