Android Development Tutorial 9



Get the Code Here: http://goo.gl/d6A10

Best Android Book : http://goo.gl/uPhXFI

Welcome to part 9 of my Android Development tutorial. In this tutorial I will focus on using the Android XmlPullParser for parsing an xml file.

I’ll be getting data from the Yahoo Web Service just like last time.

Google recommends the XmlPullParser over all others because it is fast, requires the least amount of memory and helps maintain battery life. With the video and the code above you should have no…

Related Posts

44 Comments

  1. Hi Derk ! I followed your code and used DefaultHttpClient , but it is depricated ! I found on http://developer.android.com/reference/java/net/HttpURLConnection.html that we can use HttpURLConnection and i replaced the getURLData method definition with the below code: URL urlString = new URL(url);

                 URL urlString = new URL(url);
                HttpURLConnection connection = (HttpURLConnection)     urlString.openConnection();

                InputStream in = new BufferedInputStream(connection.getInputStream());

                return in;

    But there seems some problem ! Could you help me in this !

  2. "Ingrained in your brain"  Good comment because that is what I need………..Another great tutorial.  I can't say enough how much I appreciate these tutorials!!!!!!!!!!!!!!

  3. I got through 1/3 of this tutorial (using Android Studio) before realizing you made a new set of tutorials with Android Studio. I was wondering if there was a significant difference between this tutorial and the other one?

    Also, thank you for making these videos! They're really helpful 😀

  4. Thank you very much Mr Banas! While making this app it come to my notice that Yahoo might have dropped days low and days high from their YQL response. It kinda messes up because of the array indices as the company's name shows with total volume and everything is out of place xD So if any of you guys come to this issue now, be aware of this.

  5. Hi Derek,
    I've been active in Windows development for since the beginning and finally attempted IOS development about a year ago.  HUGE learning curve for me!!
    Recently switched from iPhone to Galaxy S5, so I bit the bullet and just finished your first (8) tutorials.  You are a great developerspeaker and your tutorials are just what I needed.  Maybe it's just me, but the whole Android development experience seems to be much easiercleaner than IOS.

    Thanks for all your hard work and I look forward to completing the series!!!

    Tim

  6. Just completed this app as well. And an excellent effort bro. But need to seek your help in one thing, I could not get much logic of Xml Parsing and Java coding here so could you suggest some online material or videos that can help me in this regard.

    Thanks again.

  7. Great video as usual. Do you have a video about graph plotting (like a histogram) for live data streaming from an api or something? I'm interested in the graph part.

  8. Am lovin' these tutorials. Thanks a lot. Probably a newbie question but i notice flipping to landscape after you have added some symbols  screws up the scrollview  .. and i cant see why that should happen 🙁

  9. hi, teacher Derek. How can we learn to code for android by Android SDK source code. I know it is clear and powerful but too many methods defined in classes and so many jump-in-out, and it just like to read and to understand a big project made by others. How to use it flexible to help us better understand and improve codes or knowledge needed? Thank you 🙂 

  10. Hello Derek! thank you for this great tutorial.
    I followed the coding process in this tutorial 9, it turns out that it cannot work properly. The parser cannot track the right starting point, for example, we would like to extract the value after the tag AverageDailyVolume but the program just find the first TEXT field without checking if it associates with AverageDailyVolume.

  11. Sorry about that. Sometimes in trying not to overwhelm people with information I don't describe everything. I do provide links to all of the code for each video and the code is heavily commented.

  12. Sorry about that. Sometimes in trying not to overwhelm people with information I don't describe everything. I do provide links to all of the code for each video and the code is heavily commented.

  13. Sorry about that. Sometimes in trying not to overwhelm people with information I don't describe everything. I do provide links to all of the code for each video and the code is heavily commented.

  14. Sorry about that. Sometimes in trying not to overwhelm people with information I don't describe everything. I do provide links to all of the code for each video and the code is heavily commented.

  15. Some of the XMLPullParser stuff was glanced over very quickly as if you were trying to get through the video and I wasn't really sure what each section was supposed to do.

  16. Hello Derek,

    Super tutorials, love each and every tutorials of yours.
    However, i have a doubt in this tutorial.

    // for processing
    beginDocument(parser,"query");

    Here, you have passes query as root element but from tutorial it seems quote is the root element, so how is this code giving the right output?

    Again, thanks for all your lovely tutorials…

  17. Good question,
    Specially, what does this do?

    while ((type = parser.next()) != parser.START_TAG
    && type != parser.END_DOCUMENT) {

    ;

    }

    I know it cycles through the XML, but how?

    (type = parser.next()) != parser.START_TAG Am I assigning parser.next to type. or am I comparing type to parser.SART_TAG? or both. and why would I want to cycle through the XML anyways?

    🙂 THANKSSSSSS

  18. I added in a few extra methods in case you wanted to pull in more then one stock in the future. It is added functionality that wasn't needed, but may be needed in the future. Sorry about the confusion

  19. If you are lost in the while (like me) ((type=parser.next()) != parser.START_TAG
    && type != parser.END_DOCUMENT) {
    }
    Insert a log inside every while (and after!) like this Log.d("Inside while in BeginDocument",parser.getPositionDescription()) and after the parser.next in the do while and you will see the xml in the logcat line by line.

  20. Hi, It's probably an error with the AndroidManifest.xml that didn't get updated when you created the new StockInfoActivity… Had the same problem.

    You need to add your StockInfoActivity below the other activity.

  21. Hi. First I want to THANK YOU again and again for your GREAT tutorials! – Thank You)

    And second I would like to ask you if it is possible to make a tutorial about working with JSON-RPC. May be something like this one, but not with XML but with JSON instead.
    I think it will be very useful.

Leave a Reply

Your email address will not be published.

© 2022 Code As Pro - Theme by WPEnjoy · Powered by WordPress