Loading XML Experience...

<XML/>

eXtensible Markup Language

Press β†’ or click to begin your journey

<xml>
</xml>
<data>
</data>
<tag>
</tag>

What is Markup?

Adding meaning to text through special annotations

πŸ“
Plain Text
Just raw content without any structure or meaning attached
🏷️
Markup Language
Text + Tags that describe what the content means or how to display it
πŸ”§
Purpose
Makes data readable by both humans AND machines

XML Defined

eXtensible Markup Language

XML History

1960s

GML (Generalized Markup Language) created at IBM

1986

SGML becomes an ISO standard

1996

XML development begins at W3C

1998

XML 1.0 officially released!

XML Document Structure

Every XML document follows a precise hierarchy

<?xml version="1.0"?>
<root>
<child>
<child>
<child>

XML Declaration

The prolog tells parsers how to read the document

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
version
XML version (1.0 or 1.1)
encoding
Character encoding (UTF-8, ISO-8859-1)
standalone
External dependencies (yes/no)

XML Elements

The building blocks of every XML document

<element>Content goes here</element>
πŸ“¦
Opening Tag
<element> marks where an element begins
πŸ“„
Content
Text, child elements, or mixed content
πŸ”’
Closing Tag
</element> marks where it ends

XML Attributes

Add metadata and properties to your elements

<book id="001" category="fiction" lang="en">
<title>The Great Story</title>
</book>
βœ“ Always quoted
Values must be in single or double quotes
βœ“ In opening tag
Attributes only appear in the start tag
βœ“ Unique per element
No duplicate attribute names allowed

Nesting & Hierarchy

Elements can contain other elements, creating a tree structure

<library> <shelf id="A1"> <book> <title>XML Mastery</title> <author>Jane Doe</author> </book> <book> <title>Data Structures</title> <author>John Smith</author> </book> </shelf> </library>

Creating XML Documents

Follow these rules for well-formed XML

Entity References

How to include special characters in XML

&lt;
Less than: <
&gt;
Greater than: >
&amp;
Ampersand: &
&apos;
Apostrophe: '
&quot;
Quote: "

XML vs HTML

Click the cards to flip between the two!

XML

<person> <name>Alice</name> <age>25</age> </person>

Data description & transport

HTML

<div> <h1>Alice</h1> <p>Age: 25</p> </div>

Data display & presentation

Key Differences

XML ↔ HTML
Tags
Custom Predefined
XML ↔ HTML
Purpose
Transport Display
XML ↔ HTML
Case
Sensitive Insensitive
XML ↔ HTML
Closing Tags
Required Optional

XML Validation

Ensuring your XML follows the rules

Well-Formed
  • βœ“ Follows XML syntax rules
  • βœ“ One root element
  • βœ“ Properly nested tags
  • βœ“ Correct attribute format
Valid
  • βœ“ Well-formed AND
  • βœ“ Follows a DTD or Schema
  • βœ“ Correct element order
  • βœ“ Required elements present

DTD - Document Type Definition

A grammar that defines valid XML structure

<!-- DTD Definition --> <!DOCTYPE note [ <!ELEMENT note (to, from, heading, body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]>

XML Schema (XSD)

A more powerful alternative to DTD

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="book"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="price" type="xs:decimal"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

XML Namespaces

Avoiding naming conflicts in complex documents

<root xmlns:h="http://www.w3.org/TR/html4/" xmlns:f="http://www.furniture.com"> <h:table> <h:tr><h:td>HTML Table</h:td></h:tr> </h:table> <f:table> <f:name>Coffee Table</f:name> </f:table> </root>

XML in the Real World

XML powers many technologies you use daily

πŸ“‘ RSS Feeds
🎨 SVG Graphics
πŸ“„ Microsoft Office
🌐 SOAP Web Services
πŸ“± Android Layouts
πŸ”§ Config Files
πŸ“š eBooks (EPUB)
πŸ—ΊοΈ GPS Data (GPX)
πŸ’Ό Business Data
πŸ₯ Healthcare (HL7)

XSLT - Transforming XML

Convert XML into HTML, text, or other formats

Input XML
<catalog> <product> <name>Widget</name> <price>9.99</price> </product> </catalog>
β†’
Output HTML
<h1>Widget</h1> <p class="price"> $9.99 </p>

XPath - Navigating XML

A query language for selecting XML nodes

// Select all book elements /bookstore/book // Select book titles //book/title // Select books with price > 30 //book[price > 30] // Select first book /bookstore/book[1]

Quick Quiz! 🎯

Which statement about XML is TRUE?

XML Best Practices

Complete Example

<?xml version="1.0" encoding="UTF-8"?> <!-- Online bookstore catalog --> <bookstore xmlns="http://example.com/bookstore"> <book id="bk001" category="programming"> <title>Learning XML</title> <author> <firstName>Erik</firstName> <lastName>Ray</lastName> </author> <year>2003</year> <price currency="USD">39.95</price> <inStock>true</inStock> </book> <book id="bk002" category="web"> <title>XML &amp; Web Services</title> <author> <firstName>Ethan</firstName> <lastName>Cerami</lastName> </author> <year>2002</year> <price currency="USD">44.95</price> <inStock>false</inStock> </book> </bookstore>

Why XML Matters

🌍
Universal
Platform and language independent data exchange
πŸ“–
Self-Describing
Data carries its own meaning through tags
πŸ”§
Extensible
Create custom vocabularies for any domain
βœ…
Validatable
DTD and XSD ensure data integrity
πŸ”„
Transformable
XSLT converts to any output format
πŸ›οΈ
Standard
W3C recommendation since 1998
</>
XML
βœ“
πŸš€
πŸ“
πŸ’‘

Thank You!

Now you understand the power of XML

Structured Data
Custom Tags
Validation
Transformation
Universal Standard
1 / 25