Sometimes I need to change the value of the key sku inside of the xml files we receive from our customer. The sku sometimes needs to be changed to CCSE-9999 due to production changes.
In order to make it easier for my colleagues to do this I'm thinking about setting up a small flow where they can drop the incoming xml and then the modified xml will replace the old xml.
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.
// Is invoked each time a new job arrives in one of the input folders for the flow element.
// The newly arrived job is passed as the second parameter.
function jobArrived( s : Switch, job : Job ) {
// Create XML document object
var xmlDoc = new Document(job.getPath());
// Xpath to //order/sku node
var skuNode = xmlDoc.evalToNode("//order/sku");
// Create new SKU node and create text value of CCSE-9999
var newSKUNode = xmlDoc.createElement("sku");
var newSKUVal = xmlDoc.createText("CCSE-9999");
// Append text value onto new SKU node
newSKUNode.appendChild(newSKUVal);
// Replace old SKU node with new SKU node and save the edited XML
xmlDoc.replaceChild(newSKUNode, skuNode);
xmlDoc.save(job.getPath());
// Send to outgoing connection
job.sendToSingle(job.getPath())
}
Enfocus Switch, Enfocus PitStop Server, Enfocus PDF Review, HP SmartStream& Kodak Prinergy with RBA
Offset 72x102, Offset Large Format, Digital Large Format and Digital print.