Aral Code

XML Tutorial

XML (eXtensible Markup Language) is a way of writing structured data as text, using tags you invent yourself. It's everywhere behind the scenes: website sitemaps, RSS news feeds, SVG images, Android app layouts, Microsoft Office files, and data exchange between banks, governments and businesses.

This free course has 9 short lessons, with live examples that read, search and transform XML in your browser.

Before you start

Knowing basic HTML helps a lot, because XML looks similar. The later lessons use a little JavaScript.

What you'll be able to do

  • Write well-formed XML documents with elements and attributes
  • Validate XML with a DTD or XML Schema
  • Use namespaces and find data with XPath
  • Read XML with JavaScript and transform it with XSLT
  • Understand real XML formats like sitemaps, RSS and SVG, and compare XML with JSON

All lessons

Getting Started

  1. Introduction to XMLWhat XML is, how it differs from HTML, why it's used to store and exchange data, and where you meet XML every day.
  2. XML Syntax Rules — Well-Formed DocumentsThe rules every XML document must follow — the XML declaration, one root element, closing every tag, proper nesting, case sensitivity, quoted attributes, entities and comments.

Structure

  1. XML Elements, Attributes and Tree StructureUnderstand the XML tree of parent, child and sibling elements, choose between elements and attributes, design clear XML for records like a class list, and use namespaces.
  2. XML Validation — DTD and XML Schema (XSD)Define the allowed structure of an XML document with a DTD or an XML Schema (XSD) — required elements, data types, attributes and occurrence rules — and understand valid vs well-formed XML.

Working with XML

  1. XPath — Finding Data in XMLNavigate and search XML documents with XPath — paths, // searches, attributes with @, predicates in square brackets, and functions like count() and contains() — with a live XPath tester.
  2. Reading XML with JavaScript — DOMParser and fetchParse XML text with DOMParser, read elements and attributes with querySelector and getAttribute, display XML data as an HTML table, create XML with XMLSerializer, and load XML files with fetch.
  3. XSLT — Transforming XML into HTMLTransform XML into HTML with XSLT — templates, xsl:for-each, xsl:value-of, xsl:sort and xsl:if — and run a transformation live in the browser with XSLTProcessor.
  4. XML in Real Life — Sitemaps, RSS, SVG, Office Files and XML vs JSONSee where XML is used today — sitemap.xml for Google, RSS feeds, SVG graphics, Android layouts, Office files — and compare XML with JSON to choose the right format.
  5. XML Final Project — A School Event Feed ReaderBuild a complete XML project — design an XML file of school events with attributes and dates, check it, query it with XPath, and display it as filterable cards with JavaScript.