Skip to content
Search

Extensible Markup Language

lastmod 2025-09-25created 2014-10-2530 edits

XML (Extensible Markup Language) is a general-purpose markup language recommended by the W3C for creating other special-purpose markup languages. XML is a simplified subset of SGML, but it can be applied to describe many kinds of data. XML was created mainly to overcome the limitations of HTML by making it easy to exchange data between different systems, especially systems connected to the Internet.

XML is a kind of markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. It is defined in the XML 1.0 Specification produced by the W3C, several other related specifications, and all free open standards.

The design goals of XML emphasize simplicity, generality, and usability over the Internet. XML is a textual data format that supports the world's languages through Unicode. Although the design of XML focuses on documents, it is widely used to represent arbitrary data structures, for example in web services.

Many APIs have been developed to help software developers process XML data. Several schema systems also exist to help define XML-based languages.

<?xml version="1.0" encoding="euc-kr" standalone="no"?>

OR:

<?xml version="1.0" encoding="utf-8" ?>

Free C or C++ XML Parser Libraries

Free C or C++ XML Parser Libraries

MSXML, eXpat, TinyXML, Xerces, Arabica, libxml2, libxml++, Xmlio, XmlLite, RapidXml, XMLParser library from Frank Vanden Berghen, PugiXML, libroxml

Categories

Libraries

Python Libraries

  • xmltodict
  • xmlschema - An XML Schema validator and decoder
  • lxml - Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API.

Relationships

eXtensible Markup Language (XML)
A language for defining data with structure, data, and presentation separated
Document Type Definition (DTD) or XML Schema Definition (XSD)
Data is represented as a tree-shaped XML document by the DTD or XSD
eXtensible Stylesheet Language (XSL)
Used for the final presentation (Description).

DOM vs SAX

DOM
Loads the whole XML document into memory first, then reads values.
Because the whole XML document is loaded in memory, searching, modifying, and restructuring nodes is fast and easy.
Intuitive and simpler to parse than SAX.
Libraries - tinyxml2
SAX
Reads the XML document sequentially and fires events as nodes open and close.
It does not load and parse the whole XML document into memory, so memory usage is low and simple reading is fast.
It works by handling fired events and storing and using them in variables, so it is complex and modifying nodes is difficult.
Harder to implement than DOM.
Useful when handling very large XML.
Libraries - expat

Terms

QName (Qualified Name)
Qualified names (QNames): a QName consists of an optional namespace prefix and a local name.
e.g. <x:doc>

Pretty print XML

xmllint from libxml2

xmllint --format file.xml

(On Debian based distributions install the libxml2-utils package)

xml_pp from the XML::Twig perl module

xml_pp < file.xml

(On Debian based distributions install the xml-twig-tools package)

XMLStarlet

xmlstarlet format --indent-tab file.xml

Tidy

tidy -xml -i file.xml

Python's xml.dom.minidom

echo '<root><foo a="b">lorem</foo><bar value="ipsum" /></root>' |
  python -c 'import sys, xml.dom.minidom; print(xml.dom.minidom.parseString(sys.stdin.read()).toprettyxml())'

saxon-lint

saxon-lint --indent --xpath '/' file.xml

saxon-HE

echo '<root><foo a="b">lorem</foo><bar value="ipsum" /></root>' |
  java -cp /usr/share/java/saxon/saxon9he.jar net.sf.saxon.Query \
       -s:- -qs:/ '!indent=yes'

xidel

xidel --output-node-format=xml --output-node-indent -se . -s file.xml

Favorite site

Project

References


  1. Hyeonstorage_tistory-XML.7z ↩

  2. XML_-what_is_scheme(xsd).pdf ↩

  3. Lars.ruoff.free.fr-xmlcpp.zip ↩

author Zer0 sitemap