André says "Thank you!"

Charles Lachat charles-lachat at orange.fr
Sun Mar 15 18:07:19 EDT 2020


Hi,

Thanks to all of you for your answers to my message.

I apologize for the name of the topic; a more classical term in the forum gave rather poor results.
https://forums.livecode.com/viewtopic.php?f=7&t=33761

I’ve been following this list for over ten years and have learned a lot here; and I also know you are all very responsive.
This is why I was surprised to get no answer after my first post.

Special thanks to Mark Wieder and Mark Waddingham for their lines of code. It helps me a lot!

Charles Lachat

=================================================================
In short, if it may help someone:

1. with Mark Wiener code

on mouseUp
local idID
put revXMLCreateTree("<identity><name></name></identity>",false,true,false) into idID
revXMLPutIntoNode idID, "/identity/name", urlEncode(field 1) -- fld contains "André"
put urlDecode(revXMLText(idID,,true)) into URL ("file:"&specialFolderPath("desktop")&slash&"wieder.xml")
end mouseUp

outputs:
<?xml version="1.0"?>
<identity>
  <name>André</name>
</identity>

According to BBEdit, the file is Mac Roman

I tried this to reverse the process and it’s OK:

on mouseUp pMouseButton
local id2
put revXMLCreateTree (url ("file:"&specialFolderPath("desktop")&slash&"wieder.xml"), false, true, false) into id2
put revXMLNodeContents(id2, "identity/name") into fld 2
end mouseUp


2. with Mark Waddingham code

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(fld 1, "utf-8") -- fld contains "André"
put revXMLText(tXmlId) into URL ("file:"&specialFolderPath("desktop")&slash&"waddingham.xml")
end mouseUp

outputs:
<?xml version="1.0" encoding="UTF-8"?>
<identity><name>André</name></identity>

According to BBEdit, the file is UTF-8

I tried this to reverse the process and it’s OK:

on mouseUp pMouseButton
local id3, tXmlFile
put textDecode (url ("file:"&specialFolderPath("desktop")&slash&"waddingham.xml"),"utf-8") into tXmlFile
put revXMLCreateTree (tXmlFile, false, true, false) into id3
put revXMLNodeContents(id3, "identity/name") into fld 2
end mouseUp







More information about the use-livecode mailing list