Skip to content
Frank Stüber edited this page Oct 19, 2023 · 3 revisions

Creating a XML file

Untis is able to export its data as xml file (see official xsd). You have two options to create a xml file from Untis.

1. Interactive

You can export your data to XML from within Untis (see File > Import/Export > Untis > XML-Export).

2. Command line

You can use the command line to automate this task.

The syntax for exporting a xml file is:

Untis <Name of your gpn file> /xml[=<Name of output file>]

Example:

"c:\Program Files\Untis\2020\Untis" c:\data\sample.gpn /xml=c:\data\export.xml

For Untis MultiUser the syntax is different. Here the syntax is:

Untis DB~<School Id>~<School Year Code>~<Version> /xml[=<Name of output file>] /user=<Username> /pw=<Password>

Example:

"c:\Program Files\Untis\2020\Untis" DB~12345~2020-2021~1 /xml=c:\data\output.xml /user=Administrator /pw=qwertz

🔥 Please have a look at PSUntis, a PowerShell Module which encapsulates the Untis command line interface.

Consuming the XML file

The ENBREA UNTIS.XML library provides classes for parsing XML into entity objects which can be used for further processing.

The UntisDocument class represents the content of the XML which can be loaded from file or stream.

For each supported Xml type you will find a correspondending entity class.

Class name Description
UntisClass Represents the Untis XML type "XmlClass"
UntisDepartment Represents the Untis XML type "XmlDepartment"
UntisDescription Represents the Untis XML type "XmlDescription"
UntisGeneralSettings Represents the Untis XML type "XmlGeneralSettings"
UntisHoliday Represents the Untis XML type "XmlHoliday"
UntisLesson Represents the Untis XML type "XmlLesson"
UntisLessonDateScheme Represents the Untis XML type "XmlLessonDateScheme"
UntisLessonsTable Represents the Untis XML type "XmlLessonsTable"
UntisLessonsTableEntry Represents the Untis XML type "XmlLessonsTableEntry"
UntisLessonTime Represents the Untis XML type "XmlLessonTime"
UntisRoom Represents the Untis XML type "XmlRoom"
UntisStudent Represents the Untis XML type "XmlStudent"
UntisStudentGroup Represents the Untis XML type "XmlStudentGroup"
UntisSubject Represents the Untis XML type "XmlSubject"
UntisTeacher Represents the Untis XML type "XmlTeacher"
UntisTimeGrid Represents the Untis XML type "XmlTimegridSlot"

Example

The following sample code reads an Untis xml file and writes lesson data to the console output.

// Load XML file
var untisDocument = await UntisDocument.LoadAsync("c:\\data\\untis.xml");

// Write data for each lesson to console output
foreach (var lesson in untisDocument.Lessons)
{
  	Console.WriteLine(
		$"{lesson.Id}, "+
		$"{lesson.SubjectId}, " +
		$"{lesson.TeacherId}, " +
		$"{lesson.ValidFrom}, " +
		$"{lesson.ValidTo}");
}

Have a look at the included unit tests for more examples.

Clone this wiki locally