XML to populate Data Grid...?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
chrisGA0849
Posts: 23
Joined: Mon Dec 05, 2011 5:33 pm

XML to populate Data Grid...?

Post by chrisGA0849 » Wed May 16, 2012 5:09 am

New to Data Grids and trying to figure out how to populate a Data Grid with XML data. I’m completely lost on how to get the XML Tree to populate the DG fields with links. Any help or sample would be greatly appreciated!

Thanks..

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: XML to populate Data Grid...?

Post by monte » Wed May 16, 2012 9:24 am

It's really going to depend on your XML. Maybe post an example of what you want to parse and if you are trying to use the data in a form or table.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

chrisGA0849
Posts: 23
Joined: Mon Dec 05, 2011 5:33 pm

Re: XML to populate Data Grid...?

Post by chrisGA0849 » Wed May 16, 2012 1:59 pm

I’ve built the web service so I can tailor the XML any way needed Live Code can capture it. So for a simple design example we can use this. I would like to have it in form style with a link to the record. Maybe drop an image in the record as well... Thanks for your help!

<?xml version="1.0" ?>
- <DATABASE>
- <RECORD>
<cust_ID>40020</cust_ID>
<cust_fname>sadfsgsfgsdfg</cust_fname>
<cust_lname>sdfgsdfg</cust_lname>
</RECORD>
- <RECORD>
<cust_ID>40021</cust_ID>
<cust_fname>Chris</cust_fname>
<cust_lname>Montero</cust_lname>
</RECORD>
- <RECORD>
<cust_ID>41078</cust_ID>
<cust_fname>Chris</cust_fname>
<cust_lname>Montero</cust_lname>
</RECORD>
</DATABASE>

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: XML to populate Data Grid...?

Post by monte » Fri May 18, 2012 5:04 am

Hi Chris

Try something like this:

Code: Select all

put revCreateXMLTree(theXML,false,true,false) into tID
put 1 into theIndex
repeat for each line theRecord in revXMLChildNames(tID,"/DATABASE",cr,"RECORD",true)
     repeat for each line theField in revXMLChildNames(tID,"/DATABASE/"&theRecord,cr,,false)
        put revXMLNodeContents(pID,"/DATABASE/"&theRecord&"/"&theField) into theData[tIndex][theField]
     end repeat
     add 1 to theIndex
end repeat
revDeleteXMLTree tID
set the dgData of group "theDataGrid" to theData
The data grid side of things will be different depending on if you are using a form or table.

Cheers

Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

chrisGA0849
Posts: 23
Joined: Mon Dec 05, 2011 5:33 pm

Re: XML to populate Data Grid...?

Post by chrisGA0849 » Fri May 18, 2012 7:33 pm

Hi Monty, OK I’m done trying to figure out this XML to Data Grid Form process. I hate Data Grids! I just don’t know the syntax well enough to get this to work in my project and I need to get this working. I could figure this out if I had a working XML to Data Grid example, but can’t seem to find one anywhere!

I need a simple working stack using a Data Grid in “Form” Format that reads an XML feed, link example: (http://rss.slashdot.org/Slashdot/slashdot). $20 bucks (PayPal) if you can help me with this…

Let me know if you’re interested! From a New Frustrated Live Code Developer… UUGGGG…

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: XML to populate Data Grid...?

Post by monte » Sat May 19, 2012 12:27 pm

Hi Chris

Combining the script I wrote for you with the info from this lesson http://lessons.runrev.com/s/lessons/m/d ... -with-data should get you going but if you need more help then you can contact me at monte@goulding.ws for some consulting time.

Cheers

Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: XML to populate Data Grid...?

Post by BvG » Sat May 19, 2012 4:08 pm

I suggest not to use the datagrid when you're beginning. Use other features for a year or so, then try to use the Dartagrid again, using the lessons as guide lines. It took me several tries just to get a basic understanding about what the Datagrid _wants_ to work like (and it's not what I'd expect it to do).

Just create a list with tabs, and then put it into a field when you have set it's tabStops to something sensible. DO NOT use the "basic table field" ever. It's deprecated, but they left it in the UI because some crazy guys still use it.

That way, you can concentrate on formatting your data correctly from xml to tabular data. The datagrid does also accept tab stops, so you can "upgrade" later on, if you feel bold :)
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Post Reply