Inhaltsverzeichnis

Creating Questionnaires as XML Files (Guide for AI Assistants)

This page is meant for AI assistants (ChatGPT, Claude, Gemini, …) that create a file for SoSci Survey users, which the users then import into their survey project. The file contains questions (one section in the list of questions) and, optionally, a questionnaire that arranges these questions on pages.

Related pages:

Procedure

  1. Clarify the content with the user: questions, response options, scales, order, filters.
  2. Clarify the languages: In which language are the texts (base language)? Shall there be translations?
  3. Create the file according to the rules below and output it completely (one code block, file extension .xml).
  4. The user saves the file and imports it in SoSci Survey via List of Questions → New section → Import Questions or Other Content from an XML File. During the import, SoSci Survey asks for the ID of the new section and the name of the questionnaire. Existing contents of the project are kept.
  5. If the import reports errors or warnings, ask the user for the text of the messages and correct the file.

Complete Example

The example contains a section “LI” with a welcome text and three questions (selection, scale, open text input), English texts with a German translation, and a questionnaire with two pages and a filter.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE surveyContent SYSTEM "https://www.soscisurvey.de/templates/doctype.survey.dtd">
<surveyContent version="2.5">
<program>SoSci Survey</program>
<version>4.0.03</version>
<timestamp>2026-11-25 12:00:00</timestamp>
<title>Library Satisfaction</title>
<description>Short questionnaire on library use and satisfaction</description>
<language>eng</language>
<attributes.specific program="ofb">
<attr id="language">eng</attr>
<attr id="translations">ger</attr>
</attributes.specific>
<section>
<title>Library</title>
<attributes.specific program="ofb">
<attr id="id">LI</attr>
</attributes.specific>
<question>
<description>Welcome</description>
<class>TextContent</class>
<title />
<explanation />
<headerText>
<txt>Welcome</txt>
<txt lng="ger">Willkommen</txt>
</headerText>
<lead>
<txt><![CDATA[Thank you for taking part in our survey. It takes about 3 minutes.]]></txt>
<txt lng="ger"><![CDATA[Vielen Dank, dass Sie an unserer Befragung teilnehmen. Die Beantwortung dauert etwa 3 Minuten.]]></txt>
</lead>
<attributes.specific program="ofb">
<attr id="id">1</attr>
</attributes.specific>
</question>
<question>
<description>Frequency of use</description>
<class>select</class>
<title>
<txt>How often do you use the library?</txt>
<txt lng="ger">Wie oft nutzen Sie die Bibliothek?</txt>
</title>
<explanation />
<attributes.specific program="ofb">
<attr id="id">2</attr>
<attr id="restrictions.answered">yes</attr>
</attributes.specific>
<item>
<text>
<txt>several times a week</txt>
<txt lng="ger">mehrmals pro Woche</txt>
</text>
<attributes.specific program="ofb">
<attr id="id">1</attr>
</attributes.specific>
</item>
<item>
<text>
<txt>about once a week</txt>
<txt lng="ger">etwa einmal pro Woche</txt>
</text>
<attributes.specific program="ofb">
<attr id="id">2</attr>
</attributes.specific>
</item>
<item>
<text>
<txt>less often</txt>
<txt lng="ger">seltener</txt>
</text>
<attributes.specific program="ofb">
<attr id="id">3</attr>
</attributes.specific>
</item>
<item>
<text>
<txt>never</txt>
<txt lng="ger">nie</txt>
</text>
<attributes.specific program="ofb">
<attr id="id">4</attr>
</attributes.specific>
</item>
</question>
<question>
<description>Satisfaction</description>
<class>scale</class>
<title>
<txt>To what extent do you agree with the following statements?</txt>
<txt lng="ger">Inwieweit stimmen Sie den folgenden Aussagen zu?</txt>
</title>
<explanation />
<labels>
<li i="1">
<txt>strongly disagree</txt>
<txt lng="ger">stimme überhaupt nicht zu</txt>
</li>
<li i="5">
<txt>strongly agree</txt>
<txt lng="ger">stimme voll und ganz zu</txt>
</li>
</labels>
<residualOptions>
<li i="0">
<txt>don't know</txt>
<txt lng="ger">weiß nicht</txt>
</li>
</residualOptions>
<attributes.specific program="ofb">
<attr id="id">3</attr>
<attr id="scale.niveau">5</attr>
</attributes.specific>
<item>
<text>
<txt>I find the books I am looking for.</txt>
<txt lng="ger">Ich finde die Bücher, die ich suche.</txt>
</text>
<attributes.specific program="ofb">
<attr id="id">1</attr>
</attributes.specific>
</item>
<item>
<text>
<txt>The opening hours suit my daily life.</txt>
<txt lng="ger">Die Öffnungszeiten passen zu meinem Alltag.</txt>
</text>
<attributes.specific program="ofb">
<attr id="id">2</attr>
</attributes.specific>
</item>
<item>
<text>
<txt>It is often too noisy for me.</txt>
<txt lng="ger">Es ist mir oft zu laut.</txt>
</text>
<invert>yes</invert>
<attributes.specific program="ofb">
<attr id="id">3</attr>
</attributes.specific>
</item>
</question>
<question>
<description>Reasons for not using</description>
<class>text</class>
<title>
<txt>Why don't you use the library?</txt>
<txt lng="ger">Warum nutzen Sie die Bibliothek nicht?</txt>
</title>
<explanation />
<attributes.specific program="ofb">
<attr id="id">4</attr>
</attributes.specific>
<item>
<text />
<attributes.specific program="ofb">
<attr id="id">1</attr>
<attr id="height">120</attr>
</attributes.specific>
</item>
</question>
</section>
<questionnaire>
<title>Library Survey</title>
<attributes.specific program="ofb">
<attr id="id">library</attr>
<attr id="content">&lt;?xml version="1.0"?&gt;
&lt;questionnaire&gt;
 
&lt;page&gt;
&lt;question id="LI01" /&gt;
&lt;question id="LI02" /&gt;
&lt;/page&gt;
 
&lt;page&gt;
&lt;php&gt;&lt;![CDATA[
if (value('LI02') == 4) {
  question('LI04');
} else {
  question('LI03');
}
]]&gt;&lt;/php&gt;
&lt;/page&gt;
 
&lt;/questionnaire&gt;</attr>
</attributes.specific>
</questionnaire>
</surveyContent>

File Structure

Languages

Section and IDs

Questions

Questionnaire

Filters and PHP Code

Complete Project (Advanced)

A project file (root element <surveyProject>) contains a complete project: several sections, several questionnaires, text elements and settings. Only use it if the user explicitly wants a complete project, e.g. for a new, empty project.

Checklist Before Output