XML to Datagrid

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
Bosstone
Posts: 9
Joined: Wed Jan 08, 2020 9:55 pm

XML to Datagrid

Post by Bosstone » Tue Jan 14, 2020 8:39 pm

Hi,

I am trying to display nodes of a XML table into a Datagrid. As far as I have understand, I
put the nodes into the variable aRecords, and then, end of the loop, I put the variable aRecords
with dgData into the DataGrid.

I tried the code below, but no result will be shown in the DataGrid.

Code: Select all

private function readPreferencesToXMLTree
   
   put url("URLTO/getallexhibdata.php") into tXML
   put revXMLCreateTree(tXML, false, true, false) into tXMLTreeID
   put revXMLRootNode(tXMLTreeID) into tRoot -- "messen"
   put revXMLFirstChild(tXMLTreeID,tRoot) into tResponse -- "messe"
   repeat while "xmlerr" is not in tResponse
      put revXMLNodeContents(tXMLTreeID, tResponse & "/id") into tID
      put revXMLNodeContents(tXMLTreeID, tResponse & "/messe_1") into aRecords[tID]["messe_1"]
      put revXMLNextSibling(tXMLTreeID,tResponse) into tResponse
      if tResponse is empty then
         exit repeat
      end if
    
   end repeat
   
   set the dgData of group "DataGrid" to aRecords
   
end readPreferencesToXMLTree
What am I missing? How can I "dump" the contents of the loop?

All the best, Stefan

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: XML to Datagrid

Post by dunbarx » Tue Jan 14, 2020 10:29 pm

Hi.

Have you checked the contents of "aRecords" before you set the dgData? Is it an array?

The dgData is in array form. The dgText is in "ordinary" form.

Craig

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: XML to Datagrid

Post by Klaus » Tue Jan 14, 2020 11:07 pm

Hi Stefan,

since this is not really a "function" (in its functional sense :-) ), how do you call it?
And why is it private? 8)


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: XML to Datagrid

Post by dunbarx » Tue Jan 14, 2020 11:50 pm

Hi.

Do you see what Klaus means? It appears that your handler is a command handler, not a function handler. I am not sure how far along with LiveCode you are, so this may or may not make sense.

Assuming some other handler has called this one, please set a breakpoint right at the top at check out what is happening as you step through. But we all hope that you did not just place this into a button script, say, and click on that button. Nothing would happen if you did.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: XML to Datagrid

Post by dunbarx » Tue Jan 14, 2020 11:55 pm

Stefan.

I just looked at your other posts. You are just beginning with LiveCode. I would not get involved with a dataGrid until you are more comfortable with basic techniques. We will be here for you no matter what you do, but the dataGrid is harder to learn than LiveCode itself. :wink:

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”