Ivo Renkema
Ivo Renkema

Reputation: 2198

(Read and) Parse an XML file from Internal Storage

I have a large number of *.xml files in Internal Storage. I did not create these files myself, but I need to work with them. They are structured like so:

<?xml version="1.0" encoding="utf-16"?>
<ControlFrame xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
     xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <LandCode>31</LandCode>
     <LandName>Australia</LandName>
     <strFormat>Format35to45</strFormat>
     <bUseOverlay>true</bUseOverlay>
     ...
</ControlFrame>

The user selects one of the *.xml files from a list, and I generate a File object for the correct *.xml

Next, I need to query the *.xml file for properties like LandCode or bUseOverlay.

I have tried everything, but I can not get it to work on Jellybean 4.3.

What is my best approach and how do I implement it?

Upvotes: 0

Views: 219

Answers (1)

An SO User
An SO User

Reputation: 24998

I guess what you need is XPath.

XPath, the XML Path Language, is a query language for selecting nodes from an XML document.

There is a javax.xml.xpath that allows you to make XPath expressions and retrieve nodes.

Aside:
Pimp my XSLT is a great resource if you are planning on learning XPath.

Upvotes: 2

Related Questions