Page 1 of 1

Change Data in existing XML

Posted: Thu Jun 12, 2014 5:20 am
by arthurik
Hello LiveCode community,

is it possible to change data in existing XML File?
i try to write data with revXMLPutIntoNode. at first it looks like as it works. i write it into file and read out.
but if i read it a second time or open the XML file with editor, there is the old data.
in my test i use the example of ...7011-how-to-read-in-data-from-an-xml-file
and change the loadPreferences command to:

Code: Select all

command loadPreferences
 local tTree
    put readPreferencesToXMLTree() into tTree
    if tTree is empty then
        exit loadPreferences
    end if

if the short name of target = "writeData" then
revXMLPutIntoNode tTree, "preferences/textSize", 456
end if

processPreferencesTree tTree
revDeleteXMLTree tTree
end loadPreferences
is there an other solution to write data into XML file or see anyone my mistake.
Thank you

Re: Change Data in existing XML

Posted: Thu Jun 12, 2014 9:31 am
by Mark
Hi,

Most XML commands and functions work with the XML tree thatis in memory. First, you read the tree from the file and then you work with it while it is in memory. It stays in memory until you execute the revDeleteXMLTree command. To write the XML tree to disk, use

Code: Select all

put revXMLText(gTreeID,"/",true) into url "~/file.xml"
Kind regards,

Mark

Re: Change Data in existing XML

Posted: Thu Jun 12, 2014 10:46 pm
by arthurik
hello Mark,

i have test it now and it works.
thank you very much!!

kind regards
Arthur