Create and parse XML on the Android 3.0 platform

Use the same build, parser, and transformer APIs for XML and Android

From the developerWorks archives

Deepak Vohra

Date archived: January 24, 2019 | Last updated: April 10, 2012|First published: October 18, 2011

Android, the most commonly used smartphone platform, also functions on mobile tablets. XML is the standard medium of data exchange. You can use the same builder, parser, and transformer APIs for standard XML parsing and transformation and for Android. With the javax.xml.parsers.DocumentBuilder, you can create an org.w3c.dom.Document object. In this article, create and parse an XML document on an Android device using a DocumentBuilder object obtained from a DocumentBuilderFactory. You'll parse the XML document using an extension of an XML pull parser.

10 Apr 2012 - In response to reader comment about Listing 12 missing a line of code, the author requested the addition of this new line transformer.transform(domSource, result); immediately after this existing line: StreamResult result = new StreamResult(output).

This content is no longer being updated or maintained. The full article is provided "as is" in a PDF file. Given the rapid evolution of technology, some content, steps, or illustrations may have changed.



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Open source
ArticleID=765422
ArticleTitle=Create and parse XML on the Android 3.0 platform
publish-date=04102012