Hi All,
I'm new to LiveCode and rattling my brains as to why this fault is occurring.
The app I'm building pulls in an XML feed. If the feed has on the first line <?xml version="1.0" encoding="iso8859-1" ?> then it comes up with an error message:
"Failed to process preferences file with error: xmlerr, can't parse XML. Unsupported encoding iso8859-1"
If I copy the file to my local server and remove the first line <?xml version="1.0" encoding="iso8859-1" ?> then the app behaves as expected and correctly displays the XML fields.
I've googled for help and looked on forums that led me to believe I need to encode into UTF16. But after trying various solutions it isn't working for me, leading me to ask the experts.
Can someone please tell me where I'm going wrong.
Many thanks.
Neil
Reading XML Feed - Encoding Issues
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Reading XML Feed - Encoding Issues
Hi Neil,
Do you read the XML data from a URL? Assuming that you use LiveCode's XML external, you need something like this:
You should now be able to parse the XML data in myXML.
Actually, I would think that you could also simply delete the first line, because the XML external also parses data without document data type definition. You could try that.
Let me know if this works.
Kind regards,
Mark
Do you read the XML data from a URL? Assuming that you use LiveCode's XML external, you need something like this:
Code: Select all
put url "http://yourdomain.com/test.xml" into myXML
if the platform is "MacOS" then
put isoToMac(myXML) into myXML
end if
put uniDecode(uniEncode(line 2 to -1 of myXML),"UTF8") into myXML
put "<?xml version=" & quote & "1.0" & quote && "encoding=" & quote & "UTF8" & quote && "?>" \
& cr before myXML
Actually, I would think that you could also simply delete the first line, because the XML external also parses data without document data type definition. You could try that.
Let me know if this works.
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 6
- Joined: Thu Mar 28, 2013 8:58 pm
Re: Reading XML Feed - Encoding Issues
Hi Mark,
Thank you very much for your help, your code worked superbly.
That's one problem I'll certainly remember!
Take care,
Neil
Thank you very much for your help, your code worked superbly.
That's one problem I'll certainly remember!
Take care,
Neil