Android to pull objects from XML and loop through each?
Hi I am new to Android programming and Java. I have been searching for a good answer to this question for days. I have copied and pasted and tried my best to understand the code. I have a strong programming background in many different non OOP languages so I am super newish at Java. Anyways I was wondering if anyone can show me the absolute easiest way (somehow less than 50 lines of co开发者_开发问答de?) to pull objects from an XML file that are laid out like so:
< CDs >
< CD >
< artist >Michael Jackson< /artist >
< album >Bad< /album >
< tracks >11< /tracks >
< /CD >
...
< /CDs >
Than have Java in Android display CD0, click next button in Activity which then increments to the next CD and displays it in the same fashion. This XML file is compiled statically into the Android Project. I am using SDK 2.1-update1 and Eclipse. Thanks in advance for the help, I swear I have been trying to read through my two Java books, the Google Android website, and search Google for a good example of how to do this. I saw the SAX and XPP methods but I don't clearly understand them.
See this Example. You can store parsed result object as array of objects for later use.
Use SAX parser from the above Example. It is very simple.
精彩评论