-1

hello i am new in android i want know how to iterate child node from xml xml is as follow

    <?xml version="1.0" encoding="utf-8"?> <ACT>                
    <Item>ABC</Item>
    <Item>XYZ</Item> </ACT>

i want to take Item VAlue From ACT tag

user1153176
  • 1,006
  • 5
  • 15
  • 21

2 Answers2

0

Take a look at this answer.

Update: the code posted will only list the first Item because the loop over nodes3 in onCreate loops only over the ACT elements. Since you have only one of these, the loop will iterate once, write out the first child and then terminate. You must have a second loop inside your loop where you iterate over all child nodes of element e.

Community
  • 1
  • 1
Peter Lillevold
  • 33,668
  • 7
  • 97
  • 131
  • can you give me how to iterare that second loop in my code..see my code is i post above – user1153176 Feb 13 '12 at 04:35
  • @user1153176 - you have already done such a loop with the `nodes3` object. You should do the same inside that loop, but then with the `e` object. I will not code that for you. – Peter Lillevold Feb 13 '12 at 08:13
  • @user1153176 - glad to be of some assistance. That said, my votes goes to questions I find helpful, interesting or well written. Sorry to say that your question does not reach the bar. A friendly tip for your future questions: try to improve your spelling, put some effort into formatting, and clearly show that you are putting some effort into solving the problem yourself. Do NOT ask that people write the solution for you, this only shows that you are willing to waste others precious time on your problem. Such manners are generally not well received :) – Peter Lillevold Feb 13 '12 at 10:39
0

SAX parser is a great way to parse this kind of an xml file. Follow some SAXParsing tutorial.

  • http://as400samplecode.blogspot.in/2011/11/android-parse-xml-file-example-using.html u can check this tutorial, this is simple and easy. – Venkata Dinesh Feb 11 '12 at 11:19