Skip to first unread message

Ria Prajapati

unread,
Jul 21, 2016, 11:08:06 AM7/21/16
to MIT App Inventor Forum
So, I am trying to create an app so that when you type in an authors/famous persons name, any famous quotes by them will appear
When the url is called upon it displays the xml code shown below

Ex. you typed in Charles Dickens so:

<results>
<result>
<quote>
'A merry Christmas, uncle God save you' cried a cheerful voice. 'Bah' said Scrooge. 'Humbug'
</quote>
<author>Charles Dickens</author>
</result>

there are many more quotes that show up in the exact same format one after the other.
 How do I parse the actual quote from that and display it?

Taifun

unread,
Jul 21, 2016, 12:35:17 PM7/21/16
to MIT App Inventor Forum
I just answered the same questions some hours ago here https://groups.google.com/d/msg/mitappinventortest/5W3nPRrgJsA/KWU5Td7XAQAJ...
Did you delete your question?

Next time continue in the same thread and in case there are still questions on the same subject, then let us know in the same thread. Thank you.

Trying to push the limits of App Inventor! SnippetsTutorials and Extensions from Pura Vida Apps by  Taifun. 



Ria Prajapati

unread,
Jul 29, 2016, 11:15:18 AM7/29/16
to MIT App Inventor Forum
I've tried going through the links but nothing is working. I used the XmltextDecode block and it gave me the results..
Eg.
((results ((result (((author Charles Dickens) (quote 'A merry Christmas, uncle God save you' cried a cheerful voice. 'Bah' said Scrooge, 'Humbug'))

This just continues over and over, but next displaying the author and the following quote. However I have no idea what to do from here. I tried the lookup in pairs block but that never worked, 
 I don't know what I am doing wrong
Screen Shot 2016-07-29 at 4.13.46 PM.png

Taifun

unread,
Jul 29, 2016, 12:22:17 PM7/29/16
to MIT App Inventor Forum
use Do it to debug your blocks, see also tip 4 here
Taifun
ria.aia

Ria Prajapati

unread,
Jul 29, 2016, 1:56:55 PM7/29/16
to MIT App Inventor Forum
Hi, that helped a lot. I managed to get it to work with one quote and it worked very well, but how do I manage it for multiple quotes? when the api is called upon it provides a lot of quotes and I want to display at least 4 or 5 of them 
I tried it with 2 quotes: 
<results> <result> <quote> A scientific man ought to have no wishes, no affections, -- a mere heart of stone. </quote> <author>Charles Darwin</author> </result> <result> <quote> An American Monkey after getting drunk on Brandy would never touch it again, and thus is much wiser than most men. </quote> <author>Charles Darwin</author> </result> </results>
 however the quotes bit of lookup in pairs didn't work, and I can't get my head around why
Screen Shot 2016-07-29 at 6.49.53 PM.png

Taifun

unread,
Jul 29, 2016, 3:37:08 PM7/29/16
to mitappinv...@googlegroups.com
each bracket pair represents a list
for multiple quotes you have to put this (see screenshot) into a variable (which is a list), Then select the first or second item from the variable (list). Each item is again a list, which consists of tag/value pairs (author and quote).
After using the lookup in pairs block you then can get the quote of the selected item
Taifun


Ria Prajapati

unread,
Jul 29, 2016, 6:53:54 PM7/29/16
to MIT App Inventor Forum
Hi, thanks for the tip. I tried putting it into a list and I get the idea of it, but every time I try to do it, it keeps telling me that:
Error from Companion: Lookup in pairs: the list (not found ((author Charles Darwin) (quote A scientific man ought to have no wishes, no wishes, no affections, -- a mere heart of stone.)) 
((author Charles Darwin) (quote An American Monkey after getting drunk on Brandy would never touch it again, and thus is much wiser than most men.))) is not a well-formed list of pairs
Everything I do results in the same thing. Help

Taifun

unread,
Jul 29, 2016, 7:04:30 PM7/29/16
to MIT App Inventor Forum
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun

Ria Prajapati

unread,
Jul 31, 2016, 7:57:59 AM7/31/16
to MIT App Inventor Forum
Ok, so far I am only trying it with 2 quotes listed above. I created a variable called "list" and I have added the author and the quote to it. I managed to extract one quote out of the two but it won't let me display them 
Screen Shot 2016-07-31 at 12.55.48 PM.png
Screen Shot 2016-07-31 at 12.54.58 PM.png
Message has been deleted

Ria Prajapati

unread,
Jul 31, 2016, 8:29:15 AM7/31/16
to MIT App Inventor Forum
I GOT IT!!! It took me a lot of trial and error but I managed to finish it :)
Thanks for all your help !!! 
Screen Shot 2016-07-31 at 1.25.27 PM.png

Taifun

unread,
Jul 31, 2016, 1:40:21 PM7/31/16
to MIT App Inventor Forum
congratulations!
you are our new XML / list of lists specialist!
Taifun
Reply all
Reply to author
Forward
0 new messages