-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXML Parsing.js
51 lines (35 loc) · 1.47 KB
/
XML Parsing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
INPUTS:
xmlString -- string -- created from a SQL:ActiveRecord
e.g.: xmlString = resultRecords[0].xmlContent
OUTPUTS:
taskList -- Array/Composite Type -- an array of objects with 2 string properties:
displayName -- string -- the name of the Scriptable Task from the workflow being backed up
scriptText -- string -- the contents of the Scriptable Task as a giant text string
*/
var taskList = [];
var document = XMLManager.fromString(xmlString);
//System.log("DOCUMENT IS : \n\n"+document)
var workflowItemElementList = document.getElementsByTagName("workflow-item") ;
for (var i = 0 ; i < workflowItemElementList.length ; i++) {
var workflowItemElement
workflowItemElement = workflowItemElementList.item(i) ;
if (workflowItemElement.getAttribute("type") == "task") {
workflowChildElementList = workflowItemElement.getChildNodes()
for (j=0;j<workflowChildElementList.length;j++){
currentNode = workflowChildElementList.item(j);
currentName = currentNode.nodeName;
if (currentName=="display-name"){
taskDisplayName = currentNode.textContent;
} else if (currentName=="script"){
taskScriptText = currentNode.textContent;
}
}
System.log("CURRENT TASK NAME : "+taskDisplayName);
System.log("CONTENT IS : \n\n" + taskScriptText + "\n");
itemToAdd = null;
itemToAdd = {"displayName":taskDisplayName, "scriptText":taskScriptText};
taskList.push(itemToAdd);
System.log("ADDED TO taskList, CURRENT SCRIPT ITEM COUNT IS: " + taskList.length)
}
}