Parsing a string of XML in Android

ujcogtha

New Member
I know there's a ton of documentation on this, but I just can't get it. I've been looking for awhile and I'd like to get some help on my specific situation to shed some light on this.I used an Http Client to get a string of XML that reads:\[code\]<groups><group> <id>35</id> <sport>Racing</sport> <name>Indianapolis 500</name> <date>27/4/2012</date> <time>12:00</time> <period>PM</period> <location>Indiana</location></group><group> <id>36</id> <sport>Baseball</sport> <name>Miami Heat game</name> <date>27/4/2012</date> <time>3:00</time> <period>PM</period> <location>Miami, FL</location></group></groups>\[/code\]I have another class called XMLParser with method called takeNameGetID, it takes the whole string of XML and a string of the name it's looking for in a \[code\]<name>\[/code\] and should attempt to find the "block" that has that name and returns the corresponding \[code\]<id>\[/code\] as an integer. That is what confuses me.\[code\]public int takeNamegetID(String name, String allXML) { //This is what I can't figure out}\[/code\]I'm calling it in the first class like so:\[code\]XMLparser parser = new XMLparser();int actualId = parser.takeNamegetID(getGroupString(), getGroupXML());\[/code\]The two methods, \[code\]getGroupString()\[/code\] and \[code\]getGroupsXML()\[/code\] are rather self explanatory. One gets the name it's looking for as a string and the other gets the entire XML, respectively.What I need is an example or someone to show me the implementation of the takeNamegetID method that I want. I've been looking forever and I think it's best if I just ask for my specific problem. Thanks!
 
Back
Top