xmlwrite to multiple output files ?

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
5 posts Page 1 of 1


Posts: 3
Joined: Tue Jun 28, 2011 2:16 pm

Post by DaneRI » Wed Jun 29, 2011 3:11 pm

Is it possible to create multiple files with a dynamically created filename in an xmlwrite using "for each" on an input file from a query..


User avatar
Support Specialist
Posts: 87
Joined: Thu Mar 05, 2009 3:49 pm
Location: Ashland, NE USA

Post by Support_Julie » Tue Jul 05, 2011 4:04 pm
If you're asking if it's possible to create a generic project to write .xml files on the fly, you can't do that.

If, on the other hand, you have the XML format created, and you're reading a database file and parsing each record into a separate .xml file then giving each file a name based on something in the record, that you can do.
Julie Rosenbaum
Sr Support Analyst
e. goanywhere.support@helpsystems.com
p. 1.800.949.4696
w. HelpSystems.com


Posts: 3
Joined: Tue Jun 28, 2011 2:16 pm

Post by DaneRI » Wed Jul 06, 2011 2:17 pm
Ok. so for example. A query runs containing field a, b, and c within each of 3 records. b's value is 1 for the first record, 2 for the second and 3 for the third. I want to be able to create 3 dynamic filenames in an xmlwrite (1.xml, 2.xml, 3.xml). I am using "foreach" logic. I am looking for the syntax..




Posts: 3
Joined: Tue Jun 28, 2011 2:16 pm

Post by DaneRI » Thu Jul 07, 2011 9:45 am
I got it...I used a set variable task, then used the variable in the filename.


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

Post by LPrendergast » Wed Jan 24, 2018 11:58 am
Hi Julie, I am adding to this thread because this is an issue similar to one I have just come across. Do you have any sample projects that shows how to do this?
to summarize, 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.

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" />


5 posts Page 1 of 1