i am new to android and xml. so, i would like to know what is xml parsing and how and where we can use it in android application development. I would also like to know the syntax to be used for this purpose. thanks
3 Answers
For an introduction to XML, why not start by reading the Wikipedia entry? Basically it is a standardized way to put in form some textual data ; and it is widely used for many, various applications, online or offline.
"Parsing" means processing the XML data to extract values that can be used in your program's code.
When developing for Android, some XML files are used to store application data (e.g. UI layout, Android manifest,...) The parsing of these files is done automatically at build time by the Android Developer Tools, so you do not need to program it. For example, in this part of the Hello World tutorial, you can learn how to use the XML layout files to compose your User Interface.
If you do need an XML parser, as user Rahul recommended in this question, this great page presents three ways to parse XML on Android and shows example code.
The Android platform is an open source mobile development platform. It gives you access to all aspects of the mobile device that it runs on, from low level graphics, to hardware like the camera on a phone. With so many things possible using Android, you might wonder why you need to bother with XML. It is not that working with XML is so interesting; it is working with the things that it enables. XML is commonly used as a data format on the Internet. If you want to access data from the Internet, chances are that the data will be in the form of XML. If you want to send data to a Web service, you might also need to send XML. In short, if your Android application will leverage the Internet, then you will probably need to work with XML. Luckily, you have a lot of options available for working with XML on Android.
XML parsers Frequently used acronyms
API: Application programming interface
RSS: Really Simple Syndication
SDK: Software Developers Kit
UI: User interface
URL: Universal Resource Locator
XML: Extensible Markup Language
One of the greatest strengths of the Android platform is that it leverages the Java programming language. The Android SDK does not quite offer everything available to your standard Java Runtime Environment (JRE,) but it supports a very significant fraction of it. The Java platform has supported many different ways to work with XML for quite some time, and most of Java's XML-related APIs are fully supported on Android. For example, Java's Simple API for XML (SAX) and the Document Object Model (DOM) are both available on Android. Both of these APIs have been part of Java technology for many years. The newer Streaming API for XML (StAX) is not available in Android. However, Android provides a functionally equivalent library. Finally, the Java XML Binding API is also not available in Android. This API could surely be implemented in Android. However, it tends to be a heavyweight API, with many instances of many different classes often needed to represent an XML document. Thus, it is less than ideal for a constrained environment such as the handheld devices that Android is designed to run on. In the following sections, you will take a simple source of XML available on the Internet, and see how to parse it within an Android application using the various APIs mentioned above. First, look at the essential parts of the simple application that will use XML from the Internet.

- 11
- 1