Aral Code

Working with XML Lesson 8 of 9

XML in Real Life — Sitemaps, RSS, SVG, Office Files and XML vs JSON

See 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.

You've learned the rules of XML. Now let's look at real XML formats you'll meet as a web developer, and see how XML compares with JSON.

Sitemaps

A sitemap tells search engines which pages a website has. Websites submit it in Google Search Console:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://www.example.com/</loc>
    <lastmod>2026-12-02</lastmod>
  </url>
  <url>
    <loc>https://www.example.com/html/intro</loc>
    <lastmod>2026-12-02</lastmod>
  </url>
</urlset>

This website has one too: visit /sitemap.xml to see every lesson listed.

RSS feeds

News sites, blogs and podcasts publish their latest items in RSS so apps can show updates:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Rizal NHS Announcements</title>
    <link>https://rizalnhs.example.edu.ph</link>
    <description>Latest news from the school</description>
    <item>
      <title>Foundation Day: No classes on Friday</title>
      <link>https://rizalnhs.example.edu.ph/news/foundation-day</link>
      <pubDate>Wed, 02 Dec 2026 08:00:00 +0800</pubDate>
    </item>
  </channel>
</rss>

SVG: images made of XML

Example An SVG badge is XML
<svg width="220" height="120" xmlns="http://www.w3.org/2000/svg">
  <rect x="10" y="10" width="200" height="100" rx="16" fill="#0f5c4d"/>
  <circle cx="60" cy="60" r="28" fill="#f2b33d"/>
  <text x="100" y="68" font-family="sans-serif" font-size="22" fill="white">Aral</text>
</svg>

Because SVG is XML, every rule you've learned applies: closed tags, quoted attributes, case-sensitive names and a namespace.

Office files and Android

  • A .docx, .xlsx or .pptx file is a ZIP archive of XML files. Rename a copy to .zip, open it, and you'll find files like word/document.xml.
  • Android app screens are designed in XML layout files, like <Button android:text="Enroll"/>.
  • Many configuration files are XML: Java's Maven pom.xml, .NET .csproj project files, and server settings.

XML vs JSON

The same data in both formats:

<student lrn="136728140001">
  <name>Ana Reyes</name>
  <grade>10</grade>
  <subjects>
    <subject>Math</subject>
    <subject>ICT</subject>
  </subjects>
</student>
{
  "lrn": "136728140001",
  "name": "Ana Reyes",
  "grade": 10,
  "subjects": ["Math", "ICT"]
}
XMLJSON
SizeLonger (closing tags)Shorter
Data typesEverything is text unless a schema says otherwiseNumbers, booleans, arrays, null built in
ArraysRepeated elementsNative [ ]
Attributes, comments, namespacesYesNo
ValidationMature: DTD, XSDJSON Schema
Best forDocuments, config, Office, sitemaps, enterprise exchangeWeb APIs, JavaScript apps, mobile apps

Neither is "better". Use JSON for new web APIs and JavaScript apps; use XML when a standard requires it (sitemaps, RSS, SVG, Office, many government and business systems) or when your data is document-like, with mixed text and markup.

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. What is sitemap.xml for?
2. What is inside a .docx file?
3. Which format is usually preferred for new web APIs?
4. Why is SVG related to XML?

By Sir Reyel · Last updated 2026-12-04