Sidebar

How to create XML defaults? [closed]

0 votes
424 views
asked Nov 2, 2015 by (600 points)
closed Nov 2, 2015 by
Hello,

  I need to create a new XML document, I don't want the script having the hardcoded static values I need to populate, how can I use "template" from .createXMLMessage?

 

Or if I put the defaults in a lookup table, how can I walk "all" values in a lookup table to find them?
closed with the note: Answered it myself in the answer section!

1 Answer

0 votes

Answering my own question, as this is mostly answered in another KB articule, but putting them in a table "seams" best and then you can build your new XML as so (assuming your table has Item,Value,Enabled columns)

 

// See what tables we have
var oTableName = qie.getVariable('tablename');
 
// Get our Table (ReportMsg/ControlFileHeader)
var oTableCSV = qie.parseCSVString(oTableName, true, '"', ',', true);
 
for (var iCount=0; iCount < oTableCSV.getRowCount(); iCount++) {
   if (oTableCSV.getNode('Enabled', iCount+1) == 'True') {
 
      sItem=oTableCSV.getNode('Item', iCount+1);
      sValue=oTableCSV.getNode('Value', iCount+1);
      qie.debug(sItem + '=' + sValue);
      
      // Put into our XML object
      message.setNode(sPrefix + sItem, sValue);
 
   }
}
answered Nov 2, 2015 by (600 points)
...