Web Designing 2 - Unit 1: XML Full Notes
Unit 1: Introduction to XML
1. What is XML?
XML stands for eXtensible Markup Language. It is a markup language used to store, structure, and transport
data.
It is both human-readable and machine-readable, and allows users to define custom tags.
2. Characteristics of XML:
- Extensible: You can define your own tags.
- Structured: Stores data in hierarchical (tree) structure.
- Platform-Independent: Can be used across various platforms.
- Self-descriptive: Tags clearly describe the data.
- Unicode Supported: Supports multilingual data.
- Case-sensitive: <Name> and <name> are different.
3. XML Syntax Rules:
- Every tag must have a closing tag.
- Proper nesting of tags is mandatory.
- Only one root element per document.
- Tags and attributes are case-sensitive.
- Attribute values must be in quotes.
- Use entities for special characters.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<student>
<name>Rahul</name>
<roll>101</roll>
<course>BSc CS</course>
</student>
Web Designing 2 - Unit 1: XML Full Notes
4. Structure of XML Document:
a) Prolog Section:
Contains XML declaration and comments.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Student Data -->
b) Document Element Section:
Contains root and child elements.
Example:
<student>
<name>Priya</name>
<rollno>102</rollno>
</student>
5. XML Declaration:
It declares version and encoding of XML.
Syntax:
<?xml version="1.0" encoding="UTF-8"?>
6. Well-Formed XML Example:
<?xml version="1.0" encoding="UTF-8"?>
<university>
<student>
<name>Priya</name>
<rollno>202</rollno>
<course>MSc IT</course>
</student>
</university>
7. Common Mistakes in XML:
- Missing end tags
Web Designing 2 - Unit 1: XML Full Notes
- Improper nesting
- Not quoting attribute values
- Multiple root elements
- Using special characters (&, <) without encoding
8. Uses of XML:
- Data sharing across platforms and applications
- Configuration files in applications
- Web services (SOAP, RSS)
- Structured storage for web/mobile apps
Summary:
XML is a universal data format designed to store and share structured data in a readable and
platform-independent manner.