renderXml

View as MarkdownOpen in Claude

Render all top-level sections as a single XML document wrapped in a <prompt> root element. Each section becomes a nested XML element with its title as the tag text or attribute, and bullets/numbered lists rendered as child elements.

The markdown variant — renderMarkdown() — is the default render format. Use renderXml() only for prompts where the downstream LLM or template expects XML-structured input.

Returns

string — XML document starting with <?xml version="1.0" encoding="UTF-8"?> and wrapping all sections in a <prompt> root.

Example

1import { PomBuilder } from '@signalwire/sdk';
2
3const pom = new PomBuilder();
4pom.addSection('Intro', { body: 'Welcome.' });
5pom.addSection('Rules', { bullets: ['Be nice.', 'Stay on topic.'] });
6
7console.log(pom.renderXml());
8// <?xml version="1.0" encoding="UTF-8"?>
9// <prompt>
10// <section title="Intro">
11// <body>Welcome.</body>
12// </section>
13// ...
14// </prompt>