xml file parsing

412 views
Skip to first unread message

tadjuidje boniface

unread,
Nov 9, 2015, 11:31:35 PM11/9/15
to MIT App Inventor Forum
Hello
I have downloaded an xml file(a data base) and I was  wondering if it could be possible to store the xml file in my app
and directly parse de data from there.
if its not possible I will be open to any suggestions.
thanks

Scott Ferguson

unread,
Nov 9, 2015, 11:53:34 PM11/9/15
to MIT App Inventor Forum
You can store the xml file in the media folder then read it with the file component.
From that point the text is available to the Web component's xmldecode block, text blocks, etc.
---
sf

tadjuidje boniface

unread,
Nov 10, 2015, 10:33:32 AM11/10/15
to MIT App Inventor Forum
Hello
please I have this xml file and I wanted to help to parse the data from the xml to a list picker
so that when user pick a station from the list it automatically open the link attached to the station in the xml file
please all advice block are preferable
thanks .
Screenshot (4).png

Abraham Getzler

unread,
Nov 10, 2015, 11:35:58 AM11/10/15
to MIT App Inventor Forum

tadjuidje boniface

unread,
Nov 10, 2015, 9:02:25 PM11/10/15
to MIT App Inventor Forum
Hello
I went to the link tutorial i tried the following block but i keep getting the response
the file:///mnt/sdcard/AppINventor/bookmark does not exist.
Please can any one help me figure out the solutions
Thanks :)
Screenshot (6).png
Screenshot (7).png

tadjuidje boniface

unread,
Nov 10, 2015, 9:58:39 PM11/10/15
to MIT App Inventor Forum
Hey
Finally I was able to read the file using //bookmark.xml
but the problem is that the web component can decode the xml .it say the xml is not a valid url
so please how can solve this other issue.
Thanks

Abraham Getzler

unread,
Nov 10, 2015, 10:32:49 PM11/10/15
to MIT App Inventor Forum
Don't use Web1.Get or Web1.GotText.
You are not reading your xml text from the Web,
you are reading it from a File.

Use the File.GotText block to catch the xml text
from the File and submit it to decoding.

ABG

tadjuidje boniface

unread,
Nov 10, 2015, 11:11:20 PM11/10/15
to MIT App Inventor Forum
please which block should I use to decode the xml file
can i use the web component
thanks for your quick response

Scott Ferguson

unread,
Nov 11, 2015, 5:25:27 AM11/11/15
to mitappinv...@googlegroups.com
The XML file does have one or more errors.
One value is missing a closing quote.

Also the decoder gets hung somewhere in the second group.
I massaged the data to make it work for me by eliminating the area of the streams that generated the error.

With the massaged xml file I was able to get the genres into a listpicker.

A genre is selected.

Then a stream name is selected.

Then, if there is no problem playing the stream (the first one I tried would not play), then the stream will play.

FYI for the moderators reading this, there is an online OCR engine to convert images of text from users such as this one https://www.newocr.com/

Click Import XML.
(You can optionally click the Raw Data listpicker to view the streams and genre groups data.)
Click Genres.
Pick a Genre
Click Stream Names
Pick a stream name.
Enjoy the music (if the stream will play, some may not)


The XML documentation  hints at trial and error being used to parse these files and that was certainly the case here.

Do I use lookup in pairs here? select list item? I just tried them both until it worked.

One thing I have noticed is when you see two left parens together (( that usually means you can use lookup in pairs.

If there are three left parens ((( then you are looking at a sublist and can use select list item there.



Notes:


You can hide the URL listpicker or use a plain list for it's data instead.

I used that listpicker to help me debug the output.

Your app could automatically open the StreamsNames listpicker after a user selects a genre.

That would be better.

---

Happy Inventing!


bookmarks.xml
bookmarks.aia

tadjuidje boniface

unread,
Nov 11, 2015, 7:50:54 PM11/11/15
to MIT App Inventor Forum
thank for your help and support from you all
BEST REGARDS.


Reply all
Reply to author
Forward
0 new messages