Page 1 of 1

Tree builder from XML

Posted: Fri May 13, 2016 11:35 am
by danielrr
HI all,

Did anybody ever wrote a function to draw a tree (lines for branches, etc.) from the contents of an XML document?

best,

Daniel

Re: Tree builder from XML

Posted: Mon May 16, 2016 5:08 pm
by MaxV
Using livecode 8 you have a widget ready to use: the tree view.
So you can use this code:
########CODE#######
on mouseUp
put URL "http://livecodeitalia.blogspot.com/feeds/posts/default" into tXMLData
put revXMLCreateTree(tXMLData, true, true, true) into sXMLID
set the conID of this card to sXMLID #così recuperiamo il dato
put sXMLID into connID
put "/feed/entry" into curn
put 0 into contatore
repeat while (curn begins with "/feed")
add 1 to contatore
put curn into oldCurn
put revXMLNodeContents(connID, curn & "/title") into myData[contatore]["Title"]
put revXMLNodeContents(connID, curn & "/content") into myData[contatore]["Content"]
put revXMLNodeContents(connID, curn & "/Published") into myData[contatore]["Published"]
put revXMLNextSibling(connID, curn ) into curn
end repeat
set the arrayData of widget "Tree view" to mydata
answer fatto
revXMLDeleteAllTrees
end mouseUp
#####END OF CODE#####

That's all.

Otherwise you can use rTree: http://livecodeitalia.blogspot.it/2015/ ... lbero.html

Re: Tree builder from XML

Posted: Tue May 17, 2016 8:37 am
by danielrr
Great! In fact this is the first reason I know of to swift to 8.

Thanks a lot