Page 1 of 1
XML to populate Data Grid...?
Posted: Wed May 16, 2012 5:09 am
by chrisGA0849
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..
Re: XML to populate Data Grid...?
Posted: Wed May 16, 2012 9:24 am
by monte
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.
Re: XML to populate Data Grid...?
Posted: Wed May 16, 2012 1:59 pm
by chrisGA0849
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>
Re: XML to populate Data Grid...?
Posted: Fri May 18, 2012 5:04 am
by monte
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
Re: XML to populate Data Grid...?
Posted: Fri May 18, 2012 7:33 pm
by chrisGA0849
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…
Re: XML to populate Data Grid...?
Posted: Sat May 19, 2012 12:27 pm
by monte
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
Re: XML to populate Data Grid...?
Posted: Sat May 19, 2012 4:08 pm
by BvG
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
