Page 1 of 1

XML Tree not returning cyrillic characters

Posted: Sun Dec 20, 2020 7:01 am
by raugert
When I create a tree from an XML file (revXMLCreateTree) and parse the data to retrieve an attribute, it doesn't return the cyrillic characters. It does however return the french characters (é). I thought it might be a "textDecode" issue but the XMLData in the field is already UTF-8 textDecoded...

Here's the code in the button:

Code: Select all

on mouseUp pButtonNumber
   put empty into field "XMLDecoded"
   put revXMLCreateTree(field "XMLData", false,true,false) into tTree
   put revXMLAttributeValues(tTree,"xml/group/",person,"title",return,1) into field "XMLDecoded"
end mouseUp

thanks for any insight,
Richard
(using Livecode Indy 9.6.1 on Mac)

Here's a simple stack to illustrate.

Re: XML Tree not returning cyrillic characters

Posted: Sun Dec 20, 2020 7:36 pm
by raugert
I discovered that in order to retain cyrillic characters, the XML text must be textEncoded before creating an XML Tree. Then each attribute that may contain these cyrillic characters needs to be textDecoded.

--- This works ---

Code: Select all

on mouseUp pButtonNumber
   put empty into field "XMLDecoded"
   put textEncode (field "XMLData" , "UTF-8") into tXMLData  -- need to encode before creating tTree
   put revXMLCreateTree(tXMLData, false,true,false) into tTree
   put textDecode (revXMLAttributeValues(tTree,"xml/group/","person","title",return,1), "UTF-8") into field "XMLDecoded"  --need to decode each attribute that may contain a cyrillic character
end mouseUp
I'm not sure why I would have to encode text for an XML Tree, but in any case, it seems to work. :)

cheers,
Richard