XML Help

So i am a bit of a noob with this part. Hopefully I can get some advice or help from one of you Corona geniuses out there :slight_smile:

I have an app that I am working on for a client, it pulls a formatted XML file from a web service. This part works no problem. I can print all my info I need to extract into the terminal without any issues. This is where I am now stuck. i have been hunting the forums for an example to no avail yet. I need to take the data and put it on the screen. Here is what I was attempting…

for i=1,#events.child do  
  
 -- store the address in the message table  
 event[i] = events.child[i]  
end  
  
  
  
 for i=1,#event do  
  
 -- extract data from table and store in local variables  
 -- for easier readability/access:  
 local id = event[i].child[4].value  
 local title = event[i].child[13].child[1].value  
 local subject = event[i].child[5].value  
 --local body = event[i].child[13].child[1].value  
  
 -- print message data to terminal  
 print( "\n--------------------------------------------------" )  
 print( "To: ", id)  
 print( "From: ", title )  
 print( "Subject:", subject)  
 --print( "Body: ", body )  
  
 myText[i] = display.newText[i]("", \_W, \_H, native.systemFont, 12)  
 myText[i]:setTextColor(255, 255, 255)  
 myText[i].text = subject  
 myText[i].size = 16   
 localGroup:insert(myText[i])   
  

Like I said, I can get the data to display in the terminal without issue. but for the life of me I can not seem to figure out how to display this on the screen. What has to happen is I need the data to display in a table with one line of data linked into an image. If this was PHP for a web page I could do this easy, but the text object is giving me grief.

Thanks in advance for any help or advice :slight_smile: [import]uid: 87791 topic_id: 23797 reply_id: 323797[/import]

[lua] myText[i] = display.newText[i]("", _W, _H, native.systemFont, 12)[/lua]

try and change display.newText[i] to just display.newText [import]uid: 114118 topic_id: 23797 reply_id: 95842[/import]

@Abiz - thanks

I’ve tried it as you suggested and it did not work. I also tried moving the [i] and getting rid of it to no avail. I am thinking I am missing something, but not sure what. Most of the things I have done in Corona have just been simple games till now. This is more of a promo/business app.

Essentially what i need to happen is i need to pull XML dad file from the web with a call to the the XML web service. This I got done using examples in the XML tutorials. The file gets pulled and stored in the ‘TMP’ directory. This works perfect. The next thing I need to do is pull specific information from the file. Again using the tutorials, this is accomplished and works in the terminal. I can get and print to the terminal all the parts of the data file I need and display them there properly.

The next thing (where I am stuck) is now to take that data and put it into a formatted layout on the screen of the app. If this were a web site I would probably be using a ‘XLST’ file, or some kind of data call to the ‘XML’ and then rendering the data in a table grid of some sort with specific formatting.

I am still scouring the forums and google for any kind of examples I can find on this. But so far have not found anything Corona specific.

Again - Thank in advance for any help or advice :slight_smile:
[import]uid: 87791 topic_id: 23797 reply_id: 95932[/import]

Ok, I don’t really understand your problem, but, let’s try to help you with some idea:

Code is not tested, but basic idea is to add items with specific design in display group, and then set different x,y for every group.

local template = function(to, from, subject, group)  
 local toTxt = display.newText(to, \_W, \_H, native.systemFont, 11)  
 toTxt.x, toTxt.y = 100, 100  
  
 local fromTxt = display.newText(from, \_W, \_H, native.systemFont, 12)  
 fromTxt.x, fromTxt.y = 100, 200  
  
 local subjectTxt = display.newText(subject, \_W, \_H, native.systemFont, 13)  
 subjectTxt.x, subjectTxt.y = 100, 300  
  
 group:insert(toTxt)  
 group:insert(fromTxt)  
 group:insert(subjectTxt)  
end  
  
local data = {  
 {to = 1, subject = 1, from = 1},  
 {to = 2, subject = 2, from = 2},  
 {to = 3, subject = 3, from = 3}  
}  
  
local groups  
  
for i=1, #data do  
 local groups[i] = display.newGroup()  
 groups[i].x = i \* 100  
 groups[i].y = 200  
 template(data[i].to, data[i].from, data[i].subject, groups[i])  
end  

HTH
[import]uid: 123747 topic_id: 23797 reply_id: 95942[/import]

@marijo

THANK YOU!!!

I had to change the loop to this …

for i=1, #data do  
 local groups = display.newGroup()  
 groups.x = i \* 100  
 groups.y = 200  
 template(data[i].to, data[i].from, data[i].subject, groups)  
end  

But it works perfectly, now I just need to change the variables and set limits and use my data instead of the data loop in your example. Again a big thank you for helping me on this! [import]uid: 87791 topic_id: 23797 reply_id: 95962[/import]

Ok, so the data pulls from the web, it sorts, and displays on the screen. works great in sim and device. Now how do I do paging or scrolling with the data. It runs off the screen :confused:

I have been playing with the scrolling example, and i seem to be able to get the data into the scrollview, but it creates and layers the views. Not sure what I’m doing here. realistically what I’d like to be able to do is page the data displayed, either with the little dots showing below it or by using a

Any ideas or places I can look for examples. I tried searching the forums for data sorting and data paging, but no pertinent examples were found.

thanks in advance for any ideas, advice or help:) [import]uid: 87791 topic_id: 23797 reply_id: 96147[/import]