Change Data in existing XML

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
arthurik
Posts: 4
Joined: Thu Apr 10, 2014 6:07 am

Change Data in existing XML

Post by arthurik » Thu Jun 12, 2014 5:20 am

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

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

Re: Change Data in existing XML

Post by Mark » Thu Jun 12, 2014 9:31 am

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

arthurik
Posts: 4
Joined: Thu Apr 10, 2014 6:07 am

Re: Change Data in existing XML

Post by arthurik » Thu Jun 12, 2014 10:46 pm

hello Mark,

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

kind regards
Arthur

Post Reply