Back to blog

How to Create a .XML File in Online Notepad

Jul 3, 20262 min read

XML is plain text with a tag-based structure. Notepad writes it without any extra software. The key is following the tag rules so the file stays valid once you save it.

What is an XML file?

XML stands for Extensible Markup Language. It stores data inside custom tags you define yourself, nested to show how the data relates. Config files, data feeds, and app settings use it because the structure is easy to read and easy for other programs to parse.

A basic XML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<person>
  <name>John</name>
  <age>28</age>
  <city>New York</city>
</person>

Step-by-step: Create an XML file in Notepad

Step 1: Open Notepad

Open Notepad on your computer, or use a free online notepad if you'd rather skip the desktop app.

Step 2: Add the XML declaration

Start the file with this line:

<?xml version="1.0" encoding="UTF-8"?>

This tells any program reading the file which XML version and character encoding to expect.

Step 3: Add a root element

Every XML file needs exactly one root element that wraps everything else.

<catalog>
</catalog>

Step 4: Add child elements

Nest your data inside the root element using tags you name yourself.

<catalog>
  <book>
    <title>Sample Book</title>
    <author>Jane Doe</author>
  </book>
</catalog>

Step 5: Close Every Tag

Every opening tag needs a matching closing tag, in the same order they were opened. <book> closes with </book>, not before it.

Step 6: Save With a .xml Extension

Go to File, then Save As. Choose All Files in the "Save as type" dropdown. Name the file with a .xml extension, for example catalog.xml. Leaving the extension as .txt means the file won't be read as XML by other programs.

XML Rules To Remember

  • One root element. Everything else nests inside it. You can't have two top-level tags.

  • Tags are case-sensitive. <Name> and <name> are treated as different tags.

  • Every tag needs a close. Self-closing tags use a forward slash, like <br/>.

  • Attributes need quotes. Write <book id="1">, not <book id=1>.

  • Escape special characters. Use &amp; for &, &lt; for <, and &gt; for > inside text content.

Conclusion

An XML file is text organized into tags you define. Start with the declaration, add one root element, nest your data inside it, close every tag, and save with a .xml extension. Keep the structure visible as you write, and most errors are easy to catch before they cause a problem.

Related posts