- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 09:59 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 10:39 PM
Then change the XML payload to:
var xml = current.payload
If you want to bundle your values then use this:
//Just change this payload with "var xml = current.payload;"
var xml = '<results>' +
'<result>' +
'<row>' +
'<nodetest1>test1</nodetest1>' +
'<nodetest2>test2</nodetest2>' +
'</row>' +
'<row>' +
'<nodetest3>test3</nodetest3>' +
'<nodetest4>test4</nodetest4>' +
'</row>' +
'</result>' +
'</results>';
var count = 1;
//Parsing XML string to a xmlDoc
var xmlGrDoc = new XMLDocument2();
xmlGrDoc.parseXML(xml);
//Gets the parent node
var nodes = xmlGrDoc.getNode('//result');
var iter = nodes.getChildNodeIterator();
while(iter.hasNext()){
//Loops through each node
var n = iter.next();
var _row = '';
_row += count + '\n';
//Lets see if its a parent
var rec = n.getChildNodeIterator();
//If parent
while(rec.hasNext()){
//Lets get our row
var row = rec.next();
//Info for each row
_row += 'Node Name ' + row.getNodeName() + ' - Node Value ' + row.getTextContent() + '\n';
//gs.info('Node name: ' + row.getNodeName());
//gs.info('Node Text Content (values): ' + row.getTextContent());
//gs.info('Node value (xml string): ' + row);
}
gs.info(_row);
count++;
}
//In my xml example it will print:
*** Script: 1
Node Name nodetest1 - Node Value test1
Node Name nodetest2 - Node Value test2
*** Script: 2
Node Name nodetest3 - Node Value test3
Node Name nodetest4 - Node Value test4

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 10:03 PM
Hi
Can you show you code or the way you're displaying it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 10:26 PM
Hi Omkar,
Below is the Code which I wrote in Business Rule of ECC Queue
(function executeRule(current, previous /*null when async*/) {
var gt = current.payload;
gs.addInfoMessage(gt); // single string
var name = gs.getXMLText(current.payload, "//u_user");
gs.addInfoMessage(name); // first occurance value in the u_user tag of xml
})(current, previous);
Thanks in Advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 10:27 PM
Hi
Try something like this:
var xml = '<results>' +
'<result>' +
'<row>' +
'<test1>test1</test1>' +
'<test2>test2</test2>' +
'</row>' +
'<row>' +
'<test3>test3</test3>' +
'<test4>test4</test4>' +
'</row>' +
'</result>' +
'</results>';
//Parsing XML string to a xmlDoc
var xmlGrDoc = new XMLDocument2();
xmlGrDoc.parseXML(xml);
//Gets the parent node
var nodes = xmlGrDoc.getNode('//result');
var iter = nodes.getChildNodeIterator();
while(iter.hasNext()){
//Loops through each node
var n = iter.next();
//Lets see if its a parent
var rec = n.getChildNodeIterator();
//If parent
while(rec.hasNext()){
//Lets get our row
var row = rec.next();
//Info for each row
gs.info('Node name: ' + row.getNodeName());
gs.info('Node Text Content (values): ' + row.getTextContent());
gs.info('Node value (xml string): ' + row);
}
}
*** Script: Node name: test1
*** Script: Node Text Content (values): test1
*** Script: Node value (xml string): <test1>test1</test1>
*** Script: Node name: test2
*** Script: Node Text Content (values): test2
*** Script: Node value (xml string): <test2>test2</test2>
*** Script: Node name: test3
*** Script: Node Text Content (values): test3
*** Script: Node value (xml string): <test3>test3</test3>
*** Script: Node name: test4
*** Script: Node Text Content (values): test4
*** Script: Node value (xml string): <test4>test4</test4>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2018 10:32 PM
Hi Simon,
I can't assign the XML payload data manually,
Tell me any Solution using current.payload.
Thanks in Advance