1

I'm creating an App using LWUIT and part of its functionality is as thus, I'm using KXML 2_2-3-0 to parse my Xml files. I'm parsing two files, an XML file and an RSS feed.

This is the structure of my XML file:

<?xml version="....<the usual stuff>.....>
<kenya>
<county>
    <name>Nairobi</name>
    <population>Population: some figure</population>
    <econ>Economy: Trade and Finance</econ>
    <admin>Governor: None yet</admin>
    <constituencies>Constituencies: Under Analysis</constituencies>
    <desc>Overview: Some data</desc>
    <irating>Rating: 8/10</irating>
</county>
    <!--there are 46 more county nodes. -->
</kenya>

I'd like to have a combo box with a list of all the 47 counties, items in the combo box list should be the texts between <name></name> tags. When a user selects an item in the combo box list, info for the selected item(in this case, county), is displayed. Example, from the above XML file, the combo box item should be Nairobi, when its selected, the following is displayed,

Population: some figure Economy: Trade and Finance Governor: None yet Constituencies: Under Analysis Overview: Some data Rating: 6/10

How do I do this? I've tried using getTitle and defining the nodes but the app connects to the file(via http) but displays nothing(not even error messages). If you need to view the xml file further, just request.

George Stocker
  • 57,289
  • 29
  • 176
  • 237
Chris Mwai
  • 91
  • 1
  • 14
  • I've tried it and seems to work but not the way I had in mind. Your method works but this is what I'm trying to do, get the text between the first tags, put it in a combo box, fetch the data between the remaining tags in the block ONLY IF the item selected in the combo box corresponds to the text between the first tags in the block. Example, in a drop down list of countries, when USA is selected, the next dropdown list is a listing of the states in USA etc. Let me try setting the value in a string and use the string in the combo box and get back to you. – Chris Mwai Jul 06 '12 at 21:11

1 Answers1

3

Use the LWUIT XML parser, it works great!

Here you have an example. I did it long time ago.

XML parsing not working on android build of lwuit app

Hope it works!

Community
  • 1
  • 1
Mun0n
  • 4,438
  • 4
  • 28
  • 46