Tree builder from 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
danielrr
Posts: 142
Joined: Mon Mar 04, 2013 4:03 pm

Tree builder from XML

Post by danielrr » Fri May 13, 2016 11:35 am

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

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Tree builder from XML

Post by MaxV » Mon May 16, 2016 5:08 pm

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
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

danielrr
Posts: 142
Joined: Mon Mar 04, 2013 4:03 pm

Re: Tree builder from XML

Post by danielrr » Tue May 17, 2016 8:37 am

Great! In fact this is the first reason I know of to swift to 8.

Thanks a lot

Post Reply