XML to populate Data Grid...?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 23
- Joined: Mon Dec 05, 2011 5:33 pm
XML to populate Data Grid...?
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..
Thanks..
Re: XML to populate Data Grid...?
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/
-
- Posts: 23
- Joined: Mon Dec 05, 2011 5:33 pm
Re: XML to populate Data Grid...?
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>
<?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>
Re: XML to populate Data Grid...?
Hi Chris
Try something like this:
The data grid side of things will be different depending on if you are using a form or table.
Cheers
Monte
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
Cheers
Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- Posts: 23
- Joined: Mon Dec 05, 2011 5:33 pm
Re: XML to populate Data Grid...?
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…
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…
Re: XML to populate Data Grid...?
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
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/
Re: XML to populate Data Grid...?
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
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
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode