Xml get (create file in workflow)

I want to create a file from an xml. My file have CODEITEM that contains the part #. I have many CODEITEM lines. How can I get all lines in my new file ?

xmlget(‘/xml[1]/GLOBAL_ORDER[1]/ORDER_INFOS[1]/ORDER_ITEMS[1]/ITEMCOM[1]/CODEITEM[1]’,Value,KeepCase,NoTrim)

Hard to say without additional information. You could use the XML splitter, which would allow you to iterate on all CODEITEM elements. Or you could use a script. Or you could use an XSLT transform task.

Do you want to create another XML file or just a plain text file? Does the CODEITEM element contain a single value or does it contain sub-elements?

Please provide more context.

Phil,
I want to create a text file. Here is what it looks like:

 <ORDER_ITEMS>
    <ITEMCOM>
      <QTYCOMM>1</QTYCOMM>
      <QTYEXP>1</QTYEXP>
      <QTYSOUF/>
      <CODEITEM>701-551</CODEITEM>
      <CODEITEM2/>
      <UNITITEM>un</UNITITEM>
      <COSTITEM>27.52</COSTITEM>
      <TOTALITEM>27.52</TOTALITEM>
    </ITEMCOM>
    <ITEMCOM>
      <QTYCOMM>10</QTYCOMM>
      <QTYEXP>10</QTYEXP>
      <QTYSOUF/>
      <CODEITEM>701-513</CODEITEM>
      <CODEITEM2/>
      <UNITITEM>un</UNITITEM>
      <COSTITEM>7.02</COSTITEM>
      <TOTALITEM>70.20</TOTALITEM>
    </ITEMCOM>
  </ORDER_ITEMS>

You could use a script like the following:

// Open XML data file and read the ORDER_ITEMS element
var xmlDoc = new ActiveXObject("msxml2.DOMDocument.6.0");
xmlDoc.load(Watch.GetJobFileName());
var xmlRecs = xmlDoc.getElementsByTagName("ORDER_ITEMS");

// Create nex XML and append all elements previously read
var newDoc = new ActiveXObject("msxml2.DOMDocument.6.0");
for (var i=0; i<xmlRecs.length; i++) {
  newDoc.appendChild(xmlRecs.item(i));
}

// Save new XML to the current job file
newDoc.save(Watch.GetJobFileName());

thks Phil, I will try it

Phil, I get this

image

Change the Scripting Language to JavaScript

it works…thks Phil