XML Review

In Android, XML is used in a lot of places. Configuration, xml, value definitions, layout and many more depends on the use of XML.


eXtensible Markup Language
Simple text (Unicode) underneath
Tags (like in HTML) are used to provide information about the data
Similar to HTML, but:

  1. HTML is used to describe how to display the data
  2. XML is used to describe what is the data

Often used to store and transfer data

HTML Example

<head><title>Here goes the title</title></head.
<h1>This is a header</h1>
Here goes the text of the page

Tags mean something specific to the browser
They are used for display

XML Example

<?xml version=“1.0”/>
<phone 555-456-1234 />

Tags mean whatever the user wants them to mean
They are used to describe the data

XML Rules

Tags are enclosed in angle brackets.
Tags come in pairs with start-tags and end-tags.
Tags must be properly nested.

  1. <name><email>…</name></email> is not allowed.
  2. <name><email>…</email></name> is.

Tags that do not have end-tags must be terminated by a ‘/’.
Document has a single root element

XML Documents are Trees

The Android Manifest

<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android
<application android:icon=”@drawable/icon” android:label=”@string/app_name”>
<activity android:name=”.HelloAndroid”
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />

Highlighted in red are the xml attributes.

Leave a Reply

Your email address will not be published. Required fields are marked *