merge pdf

Sample XML Format Examples

Ready-to-use XML templates for testing, development, and learning

1. Simple XML Element

The most basic XML structure with a root element and child elements.

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to>Alice</to>
  <from>Bob</from>
  <heading>Reminder</heading>
  <body>Don't forget the meeting at 3pm!</body>
  <date>2024-06-28</date>
</note>
Format this XML Convert to JSON

2. Person / User XML

A person/user record with nested contact and address elements.

<?xml version="1.0" encoding="UTF-8"?>
<person>
  <id>usr_7f3a9b2c</id>
  <firstName>Jane</firstName>
  <lastName>Smith</lastName>
  <email>jane.smith@example.com</email>
  <phone>+1-555-234-5678</phone>
  <dateOfBirth>1992-08-15</dateOfBirth>
  <isActive>true</isActive>
  <address>
    <street>456 Olaya Street</street>
    <city>Riyadh</city>
    <country>SA</country>
    <postalCode>12346</postalCode>
  </address>
  <roles>
    <role>user</role>
    <role>editor</role>
  </roles>
</person>
Format this XML Convert to JSON

3. Book Catalog XML

A classic XML example — a catalog of books, the most commonly used demo dataset in XML tutorials.

<?xml version="1.0" encoding="UTF-8"?>
<catalog>
  <book id="bk101">
    <title>The Pragmatic Programmer</title>
    <author>David Thomas</author>
    <genre>Technology</genre>
    <price currency="USD">45.99</price>
    <publishDate>2019-09-13</publishDate>
    <isbn>978-0135957059</isbn>
    <inStock>true</inStock>
  </book>
  <book id="bk102">
    <title>Clean Code</title>
    <author>Robert C. Martin</author>
    <genre>Technology</genre>
    <price currency="USD">38.50</price>
    <publishDate>2008-08-01</publishDate>
    <isbn>978-0132350884</isbn>
    <inStock>true</inStock>
  </book>
  <book id="bk103">
    <title>Design Patterns</title>
    <author>Gang of Four</author>
    <genre>Technology</genre>
    <price currency="USD">54.99</price>
    <publishDate>1994-10-31</publishDate>
    <isbn>978-0201633610</isbn>
    <inStock>false</inStock>
  </book>
</catalog>
Convert to JSON Convert to CSV

4. XML with Attributes

XML using element attributes to store metadata — common in configuration and schema definitions.

<?xml version="1.0" encoding="UTF-8"?>
<employees company="Acme Corp" lastUpdated="2024-06-28">
  <employee id="E001" department="Engineering" level="senior">
    <name>Alice Johnson</name>
    <salary currency="USD">105000</salary>
    <startDate>2019-03-15</startDate>
  </employee>
  <employee id="E002" department="Marketing" level="junior">
    <name>Bob Williams</name>
    <salary currency="USD">68000</salary>
    <startDate>2022-07-01</startDate>
  </employee>
</employees>
Format this XML

5. RSS Feed XML

A standard RSS 2.0 feed — used by blogs, news sites and podcasts to syndicate content.

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Dconverter Blog</title>
    <link>https://www.dconverter.org/blog</link>
    <description>Developer tools tips and tutorials</description>
    <language>en-us</language>
    <lastBuildDate>Fri, 28 Jun 2024 10:00:00 GMT</lastBuildDate>
    <item>
      <title>How to Format JSON Online</title>
      <link>https://www.dconverter.org/blog/how-to-format-json</link>
      <description>Learn how to use a free online JSON formatter.</description>
      <pubDate>Mon, 15 May 2024 09:00:00 GMT</pubDate>
      <guid>https://www.dconverter.org/blog/how-to-format-json</guid>
    </item>
    <item>
      <title>XML vs JSON: Which Should You Use?</title>
      <link>https://www.dconverter.org/blog/xml-vs-json</link>
      <description>A practical comparison of XML and JSON data formats.</description>
      <pubDate>Wed, 01 May 2024 09:00:00 GMT</pubDate>
      <guid>https://www.dconverter.org/blog/xml-vs-json</guid>
    </item>
  </channel>
</rss>
Format this XML

6. Application Config XML

XML configuration file format — used in Java (web.xml), .NET (App.config), Maven (pom.xml) and Spring applications.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appSettings>
    <add key="AppName" value="MyApp" />
    <add key="Version" value="2.1.0" />
    <add key="Environment" value="production" />
  </appSettings>
  <connectionStrings>
    <add name="DefaultConnection"
         connectionString="Server=db.example.com;Database=myapp_prod;User=admin;"
         providerName="System.Data.SqlClient" />
  </connectionStrings>
  <emailSettings>
    <host>smtp.sendgrid.net</host>
    <port>587</port>
    <from>no-reply@myapp.com</from>
    <useTls>true</useTls>
  </emailSettings>
</configuration>
Convert to JSON Convert to YAML

7. SOAP Request XML

A SOAP (Simple Object Access Protocol) XML envelope — the format used by legacy web services and enterprise APIs.

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:tns="http://www.example.com/userservice">
  <soap:Header>
    <tns:AuthToken>Bearer eyJhbGciOiJIUzI1NiJ9...</tns:AuthToken>
  </soap:Header>
  <soap:Body>
    <tns:GetUserRequest>
      <tns:UserId>usr_7f3a9b2c</tns:UserId>
      <tns:IncludeRoles>true</tns:IncludeRoles>
    </tns:GetUserRequest>
  </soap:Body>
</soap:Envelope>
Format this XML

8. XML Sitemap

The standard XML sitemap format used by Google and other search engines to discover and index your website's pages.

<?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>2024-06-28</lastmod>
    <changefreq>daily</changefreq>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>https://www.example.com/about</loc>
    <lastmod>2024-05-01</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.8</priority>
  </url>
  <url>
    <loc>https://www.example.com/blog</loc>
    <lastmod>2024-06-28</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.9</priority>
  </url>
</urlset>
Validate Sitemap Generate Sitemap

Related XML Tools