XMLWrite to multiple files

If you have a new question you’d like our support staff to post a response to, please visit our customer community, GoAnywhere Insiders, to pose the question in our Discussion Boards. We have a thread “Ask Our Tech Experts” that our support team monitors on a regular basis, or you can start a new discussion where other GoAnywhere users and support staff can weigh in. Log in or create your new account at https://insiders.goanywhere.com.

If you need an immediate response, please create a support ticket or contact our support team by email at [email protected].
2 posts Page 1 of 1


Verified User
Posts: 14
Joined: Tue May 26, 2009 8:54 am

Post by LPrendergast » Thu Jan 25, 2018 2:44 pm
Hi, I have a recordset and want to write each record into its own XML file, the naming will based on the recordset ( I would use the first 4 fields of the recordset.).
My initial test names the file based on the first record but inserts each additional record into the same file instead creating separate files. If I take out the foreach loop (inside the XMLWrite) I get an error on compile. Is what I want possible? or should take totally different approach?

sample of my project below:
<project name="Item Master Create XML" mainModule="Main" version="2.0" logLevel="verbose">

<module name="Main">

<timestamp version="1.0" />

<sql label="Connect to DB" resourceId="XXXXXXX" version="1.0">
<query label="Retrieve Data" outputVariable="data">
. . . .

<forEachLoop itemsVariable="${data}" currentItemVariable="record">

<xmlWrite label="Convert to XML" outputFile="/LTPLIB/ITEM_${record[2]}_${record[3]}_${record[1]}.xml" whenFileExists="overwrite" defaultTrim="right" defaultDateFormat="yyyy-MM-dd" defaultTimeFormat="HH:mm:ss" defaultTimestampFormat="yyyy-MM-dd HH:mm:ss.SSS" outputFileVariable="xmlFile" version="1.0">
<element name="ItemMaster" value="ItemMaster ">
<forEach inputRowSetVariable="${record}">
<element name="UPC_NUMBER" value="${record[1]}">
<element name="SEASON" value="${record[2]}" />
<element name="COMPANY" value="${record[3]}" />
<element name="DIVISION" value="${record[4]}" />
<element name="STYLE" value="${record[5]}" />
<element name="STYLEDISC" value="${record[6]}" />
<element name="LENGTH" value="${record[7]}" />
<element name="COLOR" value="${record[8]}" />
<element name="SIZE" value="${record[9]}" />
<element name="CATEGORY" value="${record[10]}" />
<element name="GROUP" value="${record[11]}" />
<element name="DELIVERY" value="${record[12]}" />
<element name="MSRP" value="${record[13]}" />
<element name="SELL" value="${record[14]}" />
<element name="ATTRIBUTE01" value="${record[15]}" />
<element name="ATTRIBUTE02" value="${record[16]}" />
<element name="ATTRIBUTE03" value="${record[17]}" />
<element name="ATTRIBUTE04" value="${record[18]}" />
<element name="ATTRIBUTE05" value="${record[19]}" />
<element name="ATTRIBUTE06" value="${record[20]}" />
<element name="ATTRIBUTE07" value="${record[21]}" />
<element name="ATTRIBUTE08" value="${record[22]}" />
<element name="ATTRIBUTE09" value="${record[23]}" />
<element name="ATTRIBUTE10" value="${record[24]}" />
<element name="ATTRIBUTE11" value="${record[25]}" />
<element name="ATTRIBUTE12" value="${record[26]}" />
<element name="ATTRIBUTE13" value="${record[27]}" />
<element name="ATTRIBUTE14" value="${record[28]}" />
<element name="ATTRIBUTE15" value="${record[29]}" />
<header><?xml version="1.0" encoding="UTF-8" ?></header>


<rename label="Backup File" inputFile="${CSVFile}" newName="ITEMMASTER_${system.currentDate}" whenFileExists="overwrite" version="1.0" disabled="true" />




Support Specialist
Posts: 10
Joined: Wed Dec 13, 2017 5:52 pm

Post by Support_Jerrod » Thu Mar 15, 2018 8:47 pm
Hello Lloyd,

In this scenario, we recommend using the Print task instead of the Write XML task. Using the print task inside of a For-Each Loop will create a separate XML for each UPC number when the Append option is set to False in the advanced settings of the print task. In the print task, you will still reference the desired columns of your RowSet variable as you did in the Write XML task. You will then use the ${system.tab} variable to create the desired spacing in the output xml file. Below is a sample of how you will populate the text box of the Print task. I have also attached an example project using the Print task to write an XML file.

<?xml version="1.0" encoding="UTF-8" ?>

Thank you
Create XML with print task.xml
Example Project
(1015 Bytes) Downloaded 378 times
Jerrod Foster
Support Analyst

e. [email protected]
p. 1.800.949.4696
w. HelpSystems.com
2 posts Page 1 of 1