XML Create Data
XML document as destination
As a transfer target, the XML object creates XML code based on the configured X-Path queries.
- The XML code can be transferred further, e.g. to a database. To create an XML file, a script would be required.
For example, it comes from a table:
Author | Title |
---|---|
----- | ----- |
J.R.R. Tolkien | The Hobbit |
Joanne K. Rowling | Harry Potter and the Philosopher's Stone |
From this, an XML file with the known structure is to be generated.
- Name: “Author”, X-Path expression “/catalog/book/author”
- Name: “Title”, X-Path expression “/catalog/book/title”
For this example, you need two staggered XML objects. The first one will transform the result set into individual XML elements, the second will group the elements into one document:

-
The data records have to be written by query from a database and transferred to the X-Path elements of the first XML transfer object.
<book>
<author></author>
<title></title>
</book> -
The XML object generates the XML code. The XML object contains the well-known X-Path expressions:
-
Name: “Author”, X-Path expression “book/author”
-
Name: “Title”, X-Path expression “book/title”
as well as the basic structure
<?xml version="1.0"?>
<catalog>
</catalog>
Important is the property XML output = “Multiple XML documents”, so that each record from the database becomes its own element.The structure could also be passed dynamically at runtime. E.g. from a text file or from a database
-
-
The code is passed from the XML element to the X-Path element of the second XML transfer object. This object contains only the XML declaration and the root element:
With the X-Path query / catalog and the property XML output“One XML document” -
The code can be transferred further. Here, a script transfer object is used to create a file. File path (type: string) and XML content (type: array, string) are passed as input parameters:
public override void Write()
{
StringBuilder stb = new StringBuilder();
stb.AppendLine("<?xml version=\"1.0\"?>");
foreach(string xml in XMLContent)
{
stb.AppendLine(xml.Substring(xml.IndexOf("?>")+2));
}
System.IO.File.WriteAllText(FilePath, stb.ToString());
}