The input RowSet data used in this example is based on the example data as it appears in the
RowSet topic. Follow the steps below to write the XML file.
From within the Project Designer page, expand the Data Translation folder in the Component Library, and then drag the Write XML task to the Project Outline.
On the Basic tab of the Write XML task, specify the Output File value:
Output File
The
file path and file name of the XML file to write.
In the Write XML task window, from the
Add
button in the sub-menu, click
Element
. The first Element in the Project Outline will become the root node in the XML document.
On the Basic tab of the Element, specify a value for the following attributes:
Name
The element name as it will appear in the output XML file. An element is an XML tag. For example, <tagName>.
Enclose in CDATA
Whether or not the text in the Value attribute should be wrapped in CDATA tags.
In the Element window, from the
Add
button in the sub-menu, click
For-Each
. The XML Write task's For-Each element iterates through each row in a RowSet variable.
On the Basic tab of the For-Each element, specify the Input RowSet Variable value:
Input RowSet Variable
The name of a variable of type RowSet which contains data to write to a file. For example, ${variableName}.
In the For-Each window, from the Add
link in the sub-menu, click
Element
.
On the Basic tab for the Element, specify the Name value:
Name
The element name as it will appear in the output XML file. An element is an XML tag. For example, <tagName>.
In the Element window, from the
Add
button in the sub-menu, click
Attribute
.
On the Basic tab of the Attribute element, specify values for the following attributes:
Name
The attribute name as it will appear in the output XML file. For example, <element attributeName="attributeValue" />.
Value
The value of this attribute. This may be expressed by a combination of constant values and RowSet column references. For example ${RowSetVariable[2]}, where RowSetVariable is the name of the variable of type RowSet and 2 is the column index of that RowSet. Please note that only RowSets which are in use by a parent For-Each element may be used.
From the Project Outline, select the element above the attribute, and from the Add
link in the sub-menu, click
Element
.
On the Basic tab of the Element, specify a value for the following attributes:
Name
The element name as it will appear in the output XML file. An element is an XML tag. For example, <tagName>.
Enclose in CDATA
Whether or not the text in the Value attribute should be wrapped in CDATA tags.
If needed, add additional Attributes, from the Add
link in the sub-menu by selecting the
Add Same
option. Repeat step 11 for each attribute.
Click the
Save
button when finished.
The following image illustrates the Project Outline for the Write XML task:
The following image illustrates the XML file created from the Write XML task: