XML
02 / 02

XML: Namespaces, XPath, XSLT & Where It's Still Used

XML: Namespaces, XPath, XSLT & Where It's Still Used

Namespaces: Avoiding Tag Collisions

<library xmlns:book="http://example.com/book"
         xmlns:movie="http://example.com/movie">
  <book:title>Dune</book:title>
  <movie:title>Dune (2021)</movie:title>
</library>

<!-- Both use a <title> tag, but the namespace prefix
     disambiguates which vocabulary each belongs to -->

XPath: Querying a Document

/library/book/title       -- selects all title elements under book
//title[@lang='en']        -- any title element with lang="en", anywhere
/library/book[1]           -- the first book element

XSLT: Transforming XML

XSLT converts an XML source document into another format -- commonly HTML for display, or a restructured XML document for a different downstream consumer -- by applying declarative transformation rules.

SOAP: XML as a Messaging Protocol

SOAP is a web-services messaging protocol where every request and response is a structured XML document following a defined envelope/header/body format -- still common in enterprise and legacy B2B integration.

XML vs. JSON Today

JSON's compactness and native mapping to JavaScript objects made it the default for many modern web APIs. XML remains common where its richer feature set matters: mixed text/element content, schema validation (DTD/XSD), namespaces, and established enterprise protocols that predate or don't map cleanly onto JSON.

Mixed Content

<p>Hello <b>world</b>, welcome to <i>XML</i>!</p>

<!-- Text interleaved with child elements -- common in
     document-centric formats, rare in typical JSON usage -->

Keep your own version of these notes — editable, searchable, and organised by your stack.

Start free