Page 1 of 1

XML to Datagrid

Posted: Tue Jan 14, 2020 8:39 pm
by Bosstone

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

Re: XML to Datagrid

Posted: Tue Jan 14, 2020 10:29 pm
by dunbarx

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.


Re: XML to Datagrid

Posted: Tue Jan 14, 2020 11:07 pm
by Klaus
Hi Stefan,

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



Re: XML to Datagrid

Posted: Tue Jan 14, 2020 11:50 pm
by dunbarx

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.


Re: XML to Datagrid

Posted: Tue Jan 14, 2020 11:55 pm
by dunbarx

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: