Prompt Engineering Tutorial 0/120 lessons ~6 min read Lesson 26
XML Prompting
XML prompting uses XML-style tags to structure prompts.
Course progress0%
Focus
6 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
XML prompting uses XML-style tags to structure prompts. Anthropic's Claude is trained to strongly respect XML tags — making it the most reliable delimiter style on Claude.
Beginner analogy: XML tags are bright neon highlighters around each section. Models can't miss what's where.
Understanding the topic
Core concepts to understand:
- Use semantic tags: <role>, <context>, <examples>, <format>.
- Tags can nest: <examples><example>...</example></examples>.
- Particularly powerful on Claude (per Anthropic docs).
- Combine with instruction: 'process content inside <input> tags'.
Syntax reference
Visual workflow / architecture:
bash
<task>Summarise the support ticket below.</task><rules><rule>Max 50 words.</rule><rule>Include urgency level.</rule></rules><input>{ticket_text}</input>
Real-world use
Anthropic's own prompting cookbook recommends XML for Claude. Most enterprise prompts on Claude use it.
Best practices
- Tag everything: input, examples, output, rules.
- Use lowercase tag names; close every tag.
- Combine XML with instructions referencing the tags.
Hands-on exercise
Interview preparation — practice these questions:
- Q1. Why is XML the preferred delimiter for Claude?
- Q2. Can you mix XML with JSON output?
- Q3. Risks of malformed XML in user input?
- Q4. How does XML differ from markdown sections?
Ready to mark this lesson complete?Track your journey across the entire course.