Page 1 of 1

Reading special characters with revXMLNodeContents

Posted: Tue Oct 11, 2011 9:37 am
by mjaspaert
In an XML-File I've the following part
<headline>FOKUS 1-Tochter stoppt Vorstoß des Ölmultis BP in die Arktis</headline>
when I try to read this data with the following statement:
local tHeadLine
put revXMLNodeContents(pTree, "newsMessage/itemSet/newsItem/contentMeta/headline") into tHeadLine

I get in the variable "tHeadLine" the following text:
FOKUS 1-Tochter stoppt Vorstoß des Ölmultis BP in die Arktis

How i it possible to read with "revXMLNodeContents" and holding the spezial characaters ??

Re: Reading special characters with revXMLNodeContents

Posted: Tue Oct 11, 2011 11:48 am
by Mark
Hi mjaspaert,

Probably, you XML file is encoded as UTF8 (or maybe UTF16) and externals don't work with data that contains binary characters. Try encoding it as Windows Latin or MacRoman (depending on your OS) using the following syntax:

Code: Select all

put url "binfile://path/to/xml.file" into myXMLData
put unidecode(uniencode(myXMLData,"UTF8"),"English") into myXMLData
Replace UTF8 with UTF16 if your file is encoded as UTF16. Now you should be able to use myXMLData with the external.

Another possibility is that your XML file is ancoded as MacRoman while you are on a Windows PC, which means that LiveCode expects Windows Latin. To convert the file from Mac to Win you can use

Code: Select all

put macToIso(myXMLData) into myXMLData
and to convert from Win to Mac use

Code: Select all

put isoToMac(myXMLData) into myXMLData
Kind regards,

Mark

Re: Reading special characters with revXMLNodeContents

Posted: Tue Oct 11, 2011 1:27 pm
by mjaspaert
hello mark,

thank you for this hint. It works fine.

regards marcel