Batch 2: JavaScript HTML & CSS JSON XML YAML ← Full TOC
Ch.32 JSON Ch.33 XML Ch.34 YAML ← Full TOC

📑 Chapter 33 — XML

Complete Reference with Copy-Paste Examples
Part of The Direct Path to Linux Ubuntu — free for all students and developers.

4Topics
5Examples
python3Run
XML 1.0Version
FreeNo login
📄 Open XML Reference 🏠 XML Index
📜 Topics Covered
📄 XML Syntaxelements, attributes, namespaces, CDATA, DTD…
🔍 XPathpath expressions, predicates, axes, functions…
🐍 Python xmlElementTree, minidom, lxml, parse, generate…
🔄 XSLT & XSDtransform XML, validate with schemas…
🎓 Why Learn XML?
🏢

Enterprise Standard

SOAP web services, enterprise Java (Jakarta EE), financial systems, government data exchange — XML remains dominant in enterprise.

📖

Document-Centric

XML handles mixed content — text with inline markup — that JSON and YAML cannot. DocBook, DITA, OpenDocument use XML.

🔄

XSLT Transforms

XSLT transforms XML into HTML, PDF, other XML, or plain text — a powerful pipeline for document processing without programming.

Schema Validation

XSD schemas validate XML with rich type constraints, patterns, and occurrence rules — far more powerful than JSON Schema.

⚡ Quick Run Reference

Run a XML program:

# Python (built-in):
python3 xml_demo.py           # ElementTree (no install)
# pip install lxml            # for XPath 1.0 + XSLT + validation

# Validate XML:
xmllint --noout file.xml      # basic well-formedness
xmllint --schema schema.xsd file.xml  # XSD validation
xmllint --dtdvalid file.dtd file.xml  # DTD validation

# Apply XSLT:
xsltproc style.xsl input.xml > output.html

# Pretty-print:
xmllint --format file.xml     # indent XML
python3 -c "import sys; from xml.dom.minidom import parseString; print(parseString(sys.stdin.read()).toprettyxml())" 
Previous Home Next