ConvertCSV

XML for Beginners: Tags, Attributes, and Simple Examples

By Convert CSV Editorial TeamLast updated August 1, 2026

XML explained for beginners. Learn tags, attributes, nesting, and how XML compares to CSV and JSON—with copy-paste examples and conversion tips.

What Is XML?

XML stands for Extensible Markup Language. It is a text format for structured data using tags you (or a standards body) define—unlike HTML, which has a fixed set of tags for web pages.

You will meet XML in Office files, SVG graphics, RSS feeds, enterprise imports, and many government data portals. JSON took over most new web APIs, but XML is still everywhere in business systems.

A First Example

This document describes one book.

<?xml version="1.0" encoding="UTF-8"?>
<book id="42">
  <title>Notes on Analysis</title>
  <author>Ada Lovelace</author>
  <price currency="USD">19.99</price>
</book>

What each part means

The first line is the XML declaration. <book> is the root element. id="42" is an attribute. Nested tags hold text content. Everything is nested inside one root.

Tags, Elements, and Attributes

Three words beginners mix up—and should not.

TermMeaningExample
TagThe markup markers<title> … </title>
ElementTag + content (+ children)the whole title node
AttributeKey/value on a start tagid="42"
RootSingle top-level element<book>…</book>

Rules You Cannot Skip

XML is strict on purpose so machines do not guess.

  • Every start tag needs a matching end tag (or a self-closing tag).
  • Elements must nest—no overlapping tags.
  • Attribute values need quotes.
  • There is exactly one root element.
  • Escape &, <, and > in text (&amp; &lt; &gt;).

XML vs CSV vs JSON

Pick based on shape and audience.

NeedPrefer
Flat table for ExcelCSV
Nested data for web APIsJSON
Documents, attributes, enterprise schemasXML

Converting between them

Use XML to CSV when you need a spreadsheet. Use CSV to XML when a partner requires markup. Use CSV to JSON for web-friendly arrays.

Where Beginners Meet XML

You may not write XML from scratch, but you will open it.

  • Exporting/importing data from ERP or accounting tools.
  • Opening .svg icons or diagrams as text.
  • Reading RSS/Atom feeds.
  • Inspecting inside .xlsx files (they are ZIP + XML).
  • Uploading product or compliance feeds.

Reading XML Without Fear

Start with indentation. Pretty-printed XML shows parent/child relationships at a glance. If the file is one long line, format it with xmllint --format or your editor before reading.

For tabular data locked inside XML, convert to CSV and explore in the Online CSV Editor—often faster than learning XPath on day one.

Beginner Traps

Everyone hits these once.

  • Treating XML like HTML (unquoted attributes, unclosed tags).
  • Putting raw & in company names.
  • Adding two root elements when merging files.
  • Confusing attributes with child elements.
  • Editing XML in Excel and corrupting the structure.

Best Practices

Small habits for clean documents.

  • Always use UTF-8.
  • Pretty-print files meant for humans.
  • Validate against an XSD when the partner provides one.
  • Generate XML from clean CSV instead of hand-typing large files.
  • Keep a known-good sample next to your template.

Why Use Convert CSV Online?

Convert CSV Online is free, browser-based, and requires no account for everyday conversions. Flatten XML to CSV to learn the data, or build XML from a spreadsheet when a system demands tags. Client-side workflows work on Windows, macOS, and Linux browsers.

Learn by converting real files

Seeing the same records as XML and as CSV teaches structure faster than abstract diagrams.

Conclusion

XML is nested, tagged text with strict rules. Learn elements, attributes, and escaping, then convert to CSV when you need a table—and back to XML when a business system requires it.

FAQ

What is XML in simple terms?

XML is a text format that wraps data in custom tags so both people and programs can read structured information.

Is XML the same as HTML?

No. HTML has a fixed vocabulary for web pages. XML lets you define your own tags for data and documents, and it is stricter about nesting and quoting.

What is an XML attribute?

A named value on a start tag, such as id="42". Attributes describe the element; child elements hold nested structure or longer text.

Can I open XML in Excel?

Sometimes, but results vary. For reliable tables, convert XML to CSV first, then open the CSV in Excel.

Do I need to learn XML if I use JSON?

For many web apps, JSON is enough. Learn XML when you work with enterprise feeds, Office internals, SVG, or partner imports that require it.

How do I create XML from a spreadsheet?

Export to CSV, clean headers, then use Convert CSV Online’s CSV to XML Converter.

References

Convert your CSV in the browser

Preview, clean, and convert CSV files free with Convert CSV Online—no installation and no account required for everyday conversions.