Jainendra
Jainendra

Reputation: 25143

How to read xml file in android?

I've the following xml file inside the /mnt/sdcard. I want to get the version of the item type=provider from the following file. The file is big(500 lines) which has othere types also. This is simplified file. In the file I'm intetersted in this node:

<Item Type="Provider" Version="19.0.0.0"Checksum="EShHVeNtW1xTfEvLvATwqA==" FileSize="2746200" />

From this node I want to get the version i.e. 19.0.0.0.

Here is my xml file:

<Manifest guid="FD29E1EF-A5C4-4D19-ACC8-8C98C7E91B02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" PackageType="Full" Scope="APPROVED">
   <Items>
        <Item id="fcxm-8ikj-olk-ffgcxh3" Checksum="EShHVeNtW1xTfEvLvATwqA==" value="f425921f-b6ef-4e58-8a14-fcbd0d7e50e9" />
        <Item Type="question" Version="19.0.0.0"Checksum="EShHVeNtW1xTfEvLvATwqA==" FileSize="2746200" />
        <Item Type="Provider" Version="19.0.0.0"Checksum="EShHVeNtW1xTfEvLvATwqA==" FileSize="2746200" />
    </Items>
</Manifest>

I'm using Java code to develop my android application. I searched on the internet, I got this which is iterating to all the nodes of item type. I dont want want to iterate.

Upvotes: 1

Views: 602

Answers (1)

ila123
ila123

Reputation: 36

in android we have three normal way to parse xml, XmlPullParser, SaxXmlPullParser, DocumentBuilder(DOM parser), and android use XmlPullParser for android resource parser.

Upvotes: 2

Related Questions