Use this one-pager to get students writing well-formed XML in Visual Studio Code, with instant error catching — no paid tools required. (When you’re ready to add schemas, see the bottom.)
Open VSCode, then:
{ }:{
  "xml.server.binary.preferBinary": true,
  "xml.format.enable": true,
  "xml.format.indentSpaces": 2,
  "xml.format.lineWidth": 80,
  "xml.preferences.quoteStyle": "double",
  "xml.autoCloseTags.enabled": true,
  "editor.linkedEditing": true,
  "xml.validation.enabled": true,
  "xml.validation.schema.enabled": true,
  "xmlTools.enableXmlTreeView": true
}
xml-basics.Requires Google Drive for Desktop so your Drive appears as a local folder.
- Open your Google Drive folder on your computer.
- Right-click inside it → New → Folder (macOS: New Folder).
- Name the folder
xml-basics.
xml-basics folder you just created.
    xml-basics folder onto the VSCode window to open it.example.xml (press Enter to create it).example.xml.<?xml version="1.0" encoding="UTF-8"?>
<document>
  <title>Sample</title>
  <body>
    <p>Hello, XML!</p>
  </body>
</document>
If your XML is correct, no errors will appear.
If you make a mistake (e.g., delete a closing tag), you’ll see:
Red squiggles under the problematic part.
An entry in the Problems panel at the bottom of VSCode.
Click on a problem entry to jump directly to the error in your file.
These are the basic rules your XML must follow. VSCode (with the XML extension) will check them automatically.
One root element wrapping everything
Example: <document> ... </document>
Proper nesting (no overlaps)
✅ <a><b></b></a>
❌ <a><b></a></b>
Every start tag has an end tag
Example: <title>Sample</title> or self-closing <line/>
Attributes in quotes
Example: <person role="author">
Case-sensitive tags and attributes
<Item> ≠ <item>
Escape special characters in text
Use & for &, < for <, and > for >
Tip: Right-click → Format Document, or press Alt/Option + Shift + F to re-indent and make the structure easier to read.
Here are some frequent mistakes beginners make, and how to fix them:
Mismatched tag
Example: <titel> vs <title>
Fix: Place your cursor in the tag name and retype it. With linked editing enabled, both opening and closing tags will update.
Missing close tag
Example: <body> without </body>
Fix: Type </ and VSCode will suggest the correct closing tag.
Overlapping elements
❌ <a><b></a></b>
✅ <a><b></b></a>
Fix: Make sure tags close in the order they were opened.
Unescaped ampersand
❌ <p>Fish & Chips</p>
✅ <p>Fish & Chips</p>
Fix: Replace & with & in text nodes.
Multiple roots
❌ <title>One</title><title>Two</title>
✅ <document><title>One</title><title>Two</title></document>
Fix: Wrap everything in a single parent (root) element.
View → Problems) to see a list of issues.