How to parse Ecc Queue payload XML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2024 05:12 PM - edited 05-18-2024 06:41 PM
Hi All,
I have created BR in Scoped Application ,
In Business Rule : ECC Queue , After /insert
Please help me how to parse XML Payload, I want to parse data and push "" number, pcstatus, op "" into one array. we want to use those 3-fields values in other place
<results probe_time="1633" result_code="0">
<result>
<output>
[ { "number":"12345" , "pcstatus":"DRILL" , "op":"654" } ]
</output>
</result>
another payload , How to get seccode, secstatus, secid and errodetails of code, description.
<results probe_time="1633" result_code="0">
<result>
<output>
{ "seccode":"12345" , "secstatus":"DRILL" , "secid":"654", "errorDetails":[ {"code " :"4001", "description":"auth fail"} ] }
</output>
</result>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2024 06:46 PM
//var _strXML = '<results probe_time="1633" result_code="0"> <result> <output> [{"number":"12345" , "pcstatus":"DRILL" , "op":"654"}] </output> </result></results>';
var _strXML = current.getValue('payload');
var _objXml = new global.XMLDocument(_strXML);
var _arrResults = JSON.parse(_objXml.getNodeText('//output').trim());
gs.print(_arrResults[0], null, 4);
gs.print(_arrResults[0].number);
gs.print(_arrResults[0].pcstatus);
gs.print(_arrResults[0].op);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2024 05:56 PM
Thanks for your reply
Please help me how can I do parsing if I get different type of patrons like below [ {....} ] , {....}
get seccode, secstatus, second, code, description, code4, description4
<result>
<output>
{
"seccode":"12345" ,
"secstatus":"DRILL" ,
"secid":"654",
"errorDetails":[ {"code " :"4001", "description":"auth fail"}, {"code2" :"4001", "description2":"auth fail"}] ,
"errorDetails2":[ {"code3 " :"4001", "description3":"auth fail"}, {"code4" :"4001", "description4":"auth fail"}]
}
</output>
</result>
<result>
<output>
[ {
"seccode":"12345" ,
"secstatus":"DRILL" ,
"secid":"654",
"errorDetails":[ {"code " :"4001", "description":"auth fail"}, {"code2" :"4001", "description2":"auth fail"}] ,
"errorDetails2":[ {"code3 " :"4001", "description3":"auth fail"}, {"code4" :"4001", "description4":"auth fail"}]
} ]
</output>
</result>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2024 06:52 PM - edited 05-19-2024 06:53 PM
//var _strXML = '<results probe_time="1633" result_code="0"> <result> <output> [{"number":"12345" , "pcstatus":"DRILL" , "op":"654"}] </output> </result></results>';
var _strXML = current.getValue('payload');
var _objXml = new global.XMLDocument(_strXML);
var _jsonResults = JSON.parse(_objXml.getNodeText('//output').trim());
var _objResults = Array.isArray(_jsonResults) ? _jsonResults[0] : _jsonResults;
gs.print(JSON.stringify(_objResults, null, 4));
gs.print(_objResults.number);
gs.print(_objResults.pcstatus);
gs.print(_objResults.op);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2024 06:54 PM
Hi @Maik Skoddow
the above script about below xml format ?
<result> <output> { "seccode":"12345" , "secstatus":"DRILL" , "secid":"654", "errorDetails":[ {"code " :"4001", "description":"auth fail"}, {"code2" :"4001", "description2":"auth fail"}] , "errorDetails2":[ {"code3 " :"4001", "description3":"auth fail"}, {"code4" :"4001", "description4":"auth fail"}] } </output> </result>
<result> <output> [ { "seccode":"12345" , "secstatus":"DRILL" , "secid":"654", "errorDetails":[ {"code " :"4001", "description":"auth fail"}, {"code2" :"4001", "description2":"auth fail"}] , "errorDetails2":[ {"code3 " :"4001", "description3":"auth fail"}, {"code4" :"4001", "description4":"auth fail"}] } ] </output> </result>