Sample XML Files

Sample XML File Download

XML datasets for developer testing. Samples for parsing validation, schema (XSD) testing, and SOAP development.

Download by Size (10KB - 1MB)

Need a specific file size for load testing or benchmarking? Download automatically generated dummy files in exactly the size you need without previewing.

10 KB

Small sample for basic testing

100 KB

Medium sample for throughput testing

1 MB

Large sample for benchmark testing

Select your Sample XML Dataset

Electronics Product Inventory (Standard XML)

A valid XML product catalog with nested elements, unique IDs, and defined attributes for e-commerce testing.

<?xml version="1.0" encoding="UTF-8"?>
<catalog company="TechWorld">
  <product id="p101">
    <name>Pro Headset</name>
    <category>Audio</category>
    <price currency="USD">89.99</price>
    <specs>
      <driver>40mm</driver>
      <type>Wireless</type>
      <mic>No</mic>
    </specs>
  </product>
  <product id="p102">
    <name>Mechanical Keyboard</name>
    <category>Peripherals</category>
    <price currency="USD">129.50</price>
    <specs>
      <switches>Red</switches>
      <keys>104</keys>
    </specs>
  </product>
</catalog>
UTF-8 XML

RSS 2.0 Content Feed

A standard RSS news feed with channel metadata, items, and pubDate for testing news aggregators.

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Global Tech Daily</title>
    <link>https://example.com/rss</link>
    <description>Daily technology insights and software development news.</description>
    <language>en-us</language>
    <item>
      <title>Breaking: XML Optimization Techniques</title>
      <link>https://example.com/blog/xml-optimization</link>
      <pubDate>Thu, 28 Mar 2024 09:00:00 GMT</pubDate>
      <author>admin@example.com</author>
      <description>Exploring the latest methods for compressing large XML datasets.</description>
    </item>
  </channel>
</rss>
UTF-8 XML

SOAP API Service Envelope

A standard SOAP XML message showing Envelope, Header, and Body structures for web service testing.

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <AuthHeader xmlns="http://api.example.com/">
      <Token>S0meRand0mTok3n</Token>
    </AuthHeader>
  </soap:Header>
  <soap:Body>
    <GetUserRequest xmlns="http://api.example.com/">
      <UserID>USR_9921</UserID>
    </GetUserRequest>
  </soap:Body>
</soap:Envelope>
UTF-8 XML

Botanical Plant Database

A clean, data-driven XML file containing botanical records with both common and scientific names.

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <plant>
    <common>Bloodroot</common>
    <botanical>Sanguinaria canadensis</botanical>
    <zone>4</zone>
    <light>Mostly Shady</light>
    <price>$2.44</price>
    <availability>031599</availability>
  </plant>
  <plant>
    <common>Columbine</common>
    <botanical>Aquilegia canadensis</botanical>
    <zone>3</zone>
    <light>Mostly Shady</light>
    <price>$9.37</price>
    <availability>030699</availability>
  </plant>
</catalog>
UTF-8 XML

XML Sitemap with Metadata

An SEO sitemap instance showing loc, lastmod, and priority nodes for crawler testing.

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://example.com/</loc>
    <lastmod>2024-03-28</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>https://example.com/features</loc>
    <lastmod>2024-03-27</lastmod>
    <priority>0.7</priority>
  </url>
</urlset>
UTF-8 XML

Music CD Inventory

A hierarchical XML list of albums with artist, year, and label data.

<?xml version="1.0" encoding="UTF-8"?>
<CATALOG>
  <CD>
    <TITLE>Empire Burlesque</TITLE>
    <ARTIST>Bob Dylan</ARTIST>
    <COUNTRY>USA</COUNTRY>
    <COMPANY>Columbia</COMPANY>
    <PRICE>10.90</PRICE>
    <YEAR>1985</YEAR>
  </CD>
  <CD>
    <TITLE>Hide your heart</TITLE>
    <ARTIST>Bonnie Tyler</ARTIST>
    <COUNTRY>UK</COUNTRY>
    <COMPANY>CBS Records</COMPANY>
    <PRICE>9.90</PRICE>
    <YEAR>1988</YEAR>
  </CD>
</CATALOG>
UTF-8 XML

The Power of eXtensible Markup Language

XML (eXtensible Markup Language) is a standard for structured data interchange where data contracts and validation matter. Unlike simpler formats, XML supports comments, namespaces, and strict validation via XSD (XML Schema Definition) and DTDs.

Technical Advantages over JSON

While JSON has become the standard for modern web APIs, XML is still used for document-centric data. It is both human-readable and machine-readable, making it common in configuration files, aviation data, and financial transaction protocols.

  • Strong Typing & Validation: Using XML Schemas prevents data corruption by enforcing strict structural rules.
  • Namespaces: Allows the mixing of multiple data dialects within a single file without naming conflicts.
  • Extensible by Design: Custom tags allow the format to adapt to any industry, from botanical databases to flight logging.

Dive deeper into the industry standards at the W3C XML Portal or the Mozilla XML Hub .

XML Transformation Tools

After downloading your XML samples, use our suite of free online tools to merge files, convert them to JSON, or flatten complex hierarchies for easier analysis.

Real-World Test Scenarios

RSS Reader Development

Use the RSS 2.0 Feed sample to test your parser's ability to extract titles, links, and publication dates correctly.

Web Service (SOAP) Testing

Test enterprise web services and legacy API gateways using our SOAP Envelope sample as a mock request payload.

Validating XSD Schemas

The Plant Catalog and Sitemap samples are perfect for validating your custom XML structures against a schema.

XML File Format Specifications

The table below provides the complete technical profile of the XML format, including the W3C specification details that govern structure, encoding, and validation requirements.

PropertyValue
File Extension.xml
MIME Typeapplication/xml (or text/xml for legacy systems)
Default EncodingUTF-8 (declared in the XML prolog)
Max Recommended SizeUnder 100 MB for DOM parsing; use SAX or StAX for larger files
Governing BodyW3C (World Wide Web Consortium)
Official SpecificationXML 1.0 (5th Edition), XML 1.1
Year Introduced1998 (XML 1.0 published by W3C)
Common SoftwareVS Code, Oxygen XML Editor, MS Excel, Java, .NET, Python, any browser

How to Use a Sample XML File

XML parsing is available natively in every major programming language. Below are four complete, runnable examples covering the most common developer scenarios from reading an XML file in Python to validating it against a schema.

How to Parse an XML File in Python (ElementTree)

Python's built-in xml.etree.ElementTree module reads and traverses XML documents without any third-party dependencies.

import xml.etree.ElementTree as ET

tree = ET.parse("sample-catalog.xml")
root = tree.getroot()

# Print all product names and prices
for product in root.findall("product"):
    name = product.find("name").text
    price = product.find("price").text
    print(f"{name}: {price}")

How to Parse an XML File in JavaScript (DOMParser)

In the browser, the built-in DOMParser API converts an XML string into a traversable DOM document.

fetch("/sample-catalog.xml")
  .then((res) => res.text())
  .then((xmlString) => {
    const parser = new DOMParser();
    const doc = parser.parseFromString(xmlString, "application/xml");
    const products = doc.getElementsByTagName("product");
    Array.from(products).forEach((p) => {
      const name = p.getElementsByTagName("name")[0].textContent;
      const price = p.getElementsByTagName("price")[0].textContent;
      console.log(name + ": " + price);
    });
  });

How to Validate an XML File Against an XSD Schema

Python's lxml library makes XSD validation straightforward and produces human-readable error messages.

from lxml import etree

with open("catalog.xsd", "rb") as f:
    schema = etree.XMLSchema(etree.parse(f))

with open("sample-catalog.xml", "rb") as f:
    xml_doc = etree.parse(f)

if schema.validate(xml_doc):
    print("XML is valid.")
else:
    for error in schema.error_log:
        print(error.message, "at line", error.line)

How to Parse an RSS Feed in Python

import xml.etree.ElementTree as ET

tree = ET.parse("sample-rss.xml")
root = tree.getroot()
channel = root.find("channel")

for item in channel.findall("item"):
    title = item.find("title").text
    pub_date = item.find("pubDate").text
    print(f"{title} | {pub_date}")

How to Create Your Own XML File

XML files require a strict hierarchical structure and precise syntax. The most common mistakes are forgetting to close tags, using special characters like & and < unescaped inside element content, and omitting the XML declaration at the top of the file.

Creating an XML File Manually in a Text Editor

Every XML file should begin with the XML declaration. All elements must be properly nested and every opening tag must have a closing tag. Attribute values must be in quotes.

<?xml version="1.0" encoding="UTF-8"?>
<library>
  <book id="1">
    <title>Clean Code</title>
    <author>Robert C. Martin</author>
    <year>2008</year>
  </book>
  <book id="2">
    <title>The Pragmatic Programmer</title>
    <author>David Thomas &amp; Andrew Hunt</author>
    <year>1999</year>
  </book>
</library>

Generating an XML File in Python (minidom)

from xml.dom.minidom import getDOMImplementation

impl = getDOMImplementation()
doc = impl.createDocument(None, "library", None)
root = doc.documentElement

for data in [{"id": "1", "title": "Clean Code"}, {"id": "2", "title": "Refactoring"}]:
    book = doc.createElement("book")
    book.setAttribute("id", data["id"])
    title = doc.createElement("title")
    title.appendChild(doc.createTextNode(data["title"]))
    book.appendChild(title)
    root.appendChild(book)

with open("output.xml", "w", encoding="utf-8") as f:
    f.write(doc.toprettyxml(indent="  "))

Generating an XML File in JavaScript (Node.js)

const fs = require("fs");
const escapeXml = (s) => String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;");

const books = [
  { id: 1, title: "Clean Code" },
  { id: 2, title: "Refactoring" },
];

const lines = ['<?xml version="1.0" encoding="UTF-8"?>', "<library>"];
books.forEach((b) => {
  lines.push(`  <book id="${b.id}"><title>${escapeXml(b.title)}</title></book>`);
});
lines.push("</library>");
fs.writeFileSync("output.xml", lines.join("
"), "utf8");

Common mistakes to avoid: Always escape the five reserved XML characters inside element content: &, <, >, ', and ". Never use duplicate attribute names on the same element. Never use element names that start with a number or contain spaces.

Frequently Asked Questions about XML Files

Why use XML instead of JSON?

XML is superior when you need element attributes alongside values, require namespace support to mix multiple data dialects, or need schema enforcement via XSD. It remains the standard for SOAP web services, Office Open XML documents (.docx, .xlsx), RSS feeds, and SVG graphics. JSON is lighter and better for REST APIs where parsing speed matters more than strict validation.

How do I open an XML file on Windows or Mac?

On Windows, right-click and choose Open With > Notepad or VS Code. Double-clicking may open it in Edge, which renders a collapsible tree. On Mac, drag the file into Safari for a structured tree view, or open in TextEdit for raw editing. VS Code with the XML extension provides the best experience on both platforms.

What is the difference between XML and HTML?

HTML has fixed pre-defined tags (<div>, <p>, <a>) designed specifically for web page layout. XML tag names are entirely custom, defined by the document author or a schema, which allows it to represent anything from a product catalog to a GPS track to a music playlist.

What is an XSD file and do I need one?

An XSD (XML Schema Definition) file defines the structure, data types, and constraints for an XML file, similar to how TypeScript types define the shape of a JavaScript object. You do not need one to create or read XML, but it becomes essential in enterprise integrations where incoming XML must match an exact shape your system expects.

How do I parse XML in JavaScript?

Modern browsers provide the DOMParser API which converts an XML string into a traversable DOM document using standard methods like querySelector and getElementsByTagName. In Node.js, the xml2js package converts XML into plain JavaScript objects, which are often easier to work with programmatically.

What are the Envelope and Body elements in SOAP XML?

In SOAP protocols, the Envelope is the mandatory root element that identifies the document as a SOAP message and declares the XML namespace. The Body contains the actual request or response payload. The optional Header element carries authentication tokens, routing information, and other context for intermediary nodes.

Can I convert XML to JSON?

Yes, but conversion loses some XML-specific features like attributes and namespaces unless the tool handles them specially. In Python, the xmltodict library converts any XML document to a Python dictionary in one function call: xmltodict.parse(xml_string). The result mirrors the XML hierarchy as a nested dictionary that can then be exported as JSON.

Why is my XML file not opening or showing a parse error?

The most common causes are an unescaped ampersand or less-than sign inside element content, a missing closing tag, improperly nested tags, or an incorrect encoding declaration in the prolog. Paste your XML into xmlvalidation.com or use VS Code with the XML extension — both highlight the exact line and character where the error occurs.

Related Resources

These guides and tools will help you work more effectively with XML data, from choosing an editor to understanding how XML compares with modern alternatives.