MGD
MGD

Reputation: 783

Android Parsing XML to make a tree

I am not very old in android development, for the first time I am using XML parsing I am using this tutorial for the parsing the following file that i want to read in a tree structure, I am not able to get some tutorial to parse the file of my requirements

<?xml version="1.0" encoding="UTF-8"?>
<Items>
    <ItemData>
        <title>Fruit</title>
        <level>1</level>

        <ItemData>
            <title>Apple</title>
            <level>2</level>
        </ItemData>

        <ItemData>
            <title>Mango</title>
            <level>2</level>
        </ItemData>

        <ItemData>
            <title>Banana</title>
            <level>2</level>
        </ItemData>

    </ItemData>


    <ItemData>
        <title>Vegitables</title>
        <level>1</level>
        <ItemData>
            <title>carrot</title>
            <level>2</level>
        </ItemData>

        <ItemData>
            <title>spinach</title>
            <level>2</level>
        </ItemData>
    </ItemData>

</Items>

I just need guidance and sample code to implement my required functionality. I shall be very grateful.

Upvotes: 0

Views: 1308

Answers (1)

Developerx
Developerx

Reputation: 596

Well, in that case I think you can use one of the following parser resources to check out a working sample:

  1. SAX project: Quick start guide
  2. A more detailed and extensive explanation of how SAX works, with code samples: Sun tutorials
  3. Tutorial with DOM vs SAX diff and samples : more on DOM and SAX

Hope above helps. It might help if you post some of errors you are facing?

Upvotes: 2

Related Questions