Reading special characters with revXMLNodeContents

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mjaspaert
Posts: 4
Joined: Tue Jan 18, 2011 8:40 am

Reading special characters with revXMLNodeContents

Post by mjaspaert » Tue Oct 11, 2011 9:37 am

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 ??

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Reading special characters with revXMLNodeContents

Post by Mark » Tue Oct 11, 2011 11:48 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mjaspaert
Posts: 4
Joined: Tue Jan 18, 2011 8:40 am

Re: Reading special characters with revXMLNodeContents

Post by mjaspaert » Tue Oct 11, 2011 1:27 pm

hello mark,

thank you for this hint. It works fine.

regards marcel

Post Reply