Charles Hartmann

unread,
Sep 20, 2017, 8:01:01 AM9/20/17
to mitappinv...@googlegroups.com

I've got an xml file im trying to read from the web component. Im trying to use lookup in pairs but am not having any success. I've read many of the tutorials online how to do it but i keep getting a blank list. any help would be greatly appreciated :)


Here is a link to the xml file im trying to use https://www.fantasyfootballnerd.com/service/nfl-teams/xml/test


I have also attached the .aia file if that is any easier to look at



Here is the error i get





TestXML (2).aia

Evan Patton

unread,
Sep 20, 2017, 2:56:41 PM9/20/17
to MIT App Inventor Forum
Hi Charles,

I think the issue here is that your lookup in pairs blocks are in reverse. For example, before the first block can execute, it will need to evaluate the second parameter (which is also a lookup in pairs) recursively, until it gets to the innermost lookup in pairs, which you have as looking up "fullName". If you reverse the order, so that NFLTeams is retrieved first, then I think it should work.

For more info, please see this document on using lookup in pairs with decoded XML.

Cheers,
Evan

Taifun

unread,
Sep 20, 2017, 5:27:06 PM9/20/17
to MIT App Inventor Forum
see my answer here https://community.thunkable.com/t/please-help-with-xml-parsing/7851/4?u=taifun
Taifun
PS there is no need to ask the same question in different forums...

Charles Hartmann

unread,
Sep 21, 2017, 4:59:04 AM9/21/17
to mitappinv...@googlegroups.com
@ Evan I tried putting the pairs in reverse and that did not work :/ I have see. That document as well, it was helpful in understanding but I was still not able to get it to work.

Charles Hartmann

unread,
Sep 21, 2017, 4:59:46 AM9/21/17
to mitappinv...@googlegroups.com
see my answer here https://community.thunkable.com/t/please-help-with-xml-parsing/7851/4?u=taifun
Taifun
PS there is no need to ask the same question in different forums...

@Taifun I responded to your answer. I read the documents you provided taifun, and appreciate your help very much. Unfortunately I was not able to get any results. I asked on this forum because there is a much wider audience and better chance of me getting help I thought. Thunkable is great, I love it. No nock on it whatsoever, just thought I'd have better luck here.

Ghica

unread,
Sep 21, 2017, 5:35:20 AM9/21/17
to MIT App Inventor Forum
Your code has an obvious problem. If you do a lookup in pairs, you return "not found" if you did not find anything. That is ok if you do not anything further with it. But you are doing nested lookups, so if you are trying to do the second lookup in pairs on not found, you will get an error because you are trying to lookup in something that is not a list of lists of 2 elements. So, either you should not do the lookup in a nested way (which I believe is better, because then you can find out where you go wrong, using a notifier for example) or make the not found parameter into a list which has a list of two elements as element.
You should alsways test for input that is not perfect or, in this case, where your processing is not right. If I look at your XML, you are ignoring the code attribute and you are missing the fact that Team is not a list of pairs.
Cheers, Ghica.

Ghica

unread,
Sep 21, 2017, 6:56:33 AM9/21/17
to mitappinv...@googlegroups.com

Here is a version that works (I saw another problem: you were reusing a local variable as input and also as output, moreover, you were trying lookup in pairs on something that is not a list.
To note also is that after you found NFLTeams and Team, you get a list of a list of pairs, so you have to go through the list and for each element do a lookup in pairs.
I attach an image of the highlights of my blocks.
See my super-practical path procedure that can look through a nested pairs list. For the GetTeamname, I forgot to remove the XML parameter. I decoded the XML in the Screen1.Initialize into global rawDecoded.
Cheers, Ghica.



TestXML2 (1).aia

Charles Hartmann

unread,
Sep 21, 2017, 12:46:45 PM9/21/17
to MIT App Inventor Forum
Thank you very much Ghica. Its much easier for me to understand what is going on when i have a visual. Im still learning with app inventor and any coding in general. much appreciated.
Reply all
Reply to author
Forward
0 new messages