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 <section> element with its title, body, and bullets rendered as child elements.

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

Parameters

None.

Returns

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

Example

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