Advanced Prompt Engineering / Advanced Prompt Structures

XML/Markup Prompting

Intermediate [3/5]
Tag-based prompting Hierarchical markup prompting

Definition

XML/Markup prompting uses XML-style tags to structure prompts and expected outputs. Tags create clear boundaries between different sections of a prompt, making it easier for the model to parse and follow complex instructions.

This technique is particularly effective with Claude and other models trained on structured data formats.

Key Concepts

  • Section delimiters: Tags like <instructions>, <context>, <input>
  • Hierarchical structure: Nested tags for complex organization
  • Output formatting: Requesting responses in matching tag structure
  • Clear boundaries: Unambiguous separation of prompt components

Examples

Input Structure
Organized Prompt
<instructions> Analyze the customer feedback and provide a summary. </instructions> <context> This feedback is from our mobile app users after the v2.0 release. </context> <feedback> The new interface is confusing. I can't find the settings anymore. Loading times have improved though! </feedback> <output_format> - Key issues - Positive points - Recommended actions </output_format>
Output Structure
Tagged Response
Respond using this structure: <analysis> <summary>Brief overview</summary> <sentiment>positive/negative/neutral</sentiment> <key_points> <point>First point</point> <point>Second point</point> </key_points> <recommendation>Action to take</recommendation> </analysis>

Interactive Exercise

Structure with XML Tags

Convert this flat prompt into XML-structured format:

Flat: "You are a translator. Translate the following English text to French. The text is: Hello, how are you? Keep it formal."

Pro Tips
  • Use descriptive tag names that explain content
  • Keep nesting levels manageable (2-3 deep max)
  • Be consistent with tag naming conventions
  • Claude particularly responds well to XML structure

Related Terms