You need to sign in to do that
Don't have an account?
Gaurav Jain 67
How to Parse a XML which is present as a small section in a JSON format API response
I need to parse a value 'TotalMatchScore' from the small XML sectionof the below JSON code:
{
"Header": {
"Source": "SFDC",
"UniqueId": "XXXXXX",
"Target": "ServiceName",
"DateTime": "2018-10-26 11:33:13"
},
"Detail": {
"ApplicationID": "xxx",
"BureauStatus": "Success",
"BureauError": {
"ErrorCode": null,
"ErrorMessage": null
},
"BureauResponse": [
{
"ApplicantID": null,
"ProcessedRequest": [
{
"@nil": "",
"BureauId": 11,
"BureauProduct": {
"@nil": "true",
"BureauId": null,
"CategoryAlias": null,
"IsALL": null,
"IsActive": null,
"IsEnquiryCreated": null,
"LOSId": null,
"Priority": null,
"ProductCode": {
"@nil": ""
},
"ProductId": null,
"ProductName": {
"@nil": ""
},
"RefNo": null,
"RuleIdList": {
"@nil": ""
}
},
"ConsumerName": {
"@nil": "true"
},
"Error": {
"@nil": "true"
},
"ErrorCode": {
"@nil": "true"
},
"ErrorDetail": {
"@nil": "true"
},
"ExistingRefNo": 0,
"LOSApplicationNo": {
"@nil": "",
"$": "XXXXXX"
},
"ProcessingTime": {
"@nil": "",
"$": "00:00:01.9591036"
},
"ReferenceNumber": 94717,
"ResponseType": "Normal",
"ResponseXML": {
"@nil": "",
"$": "<ResultBlock><MatchSummary matches=\"0\"><TotalMatchScore /></MatchSummary><ErrorWarnings><Errors errorCount=\"0\" /><Warnings warningCount=\"1\"><Warning><Number>102009</Number><Message>Match schemes not used</Message><Values><Value>317</Value><Value>318</Value><Value>676</Value><Value>64</Value><Value>138</Value><Value>141</Value><Value>142</Value><Value>145</Value></Values></Warning></Warnings></ErrorWarnings></ResultBlock>"
},
"Status": {
"@nil": "",
"$": "Finished"
},
"TimeOutStatus": {
"@nil": "",
"$": "NoHit"
},
"XMLFileName": {
"@nil": "true"
}
}
]
}
],
"BreStatus": "Error",
"BreError": {
"ErrorCode": "TW-001",
"ErrorMessage": "Evaluation error \nExpression produces unexpected value: Invalid index: 0.\nInvalid index: 0 while evaluating function fn_Definitions "
},
"BREResponse": [
{
"response": {
"systemDecision": null,
"systemDecisionDateTime": null,
"strategyUsed": null,
"finalApprovalLevel": null,
"policyRulesDecision": null,
"scoreDecision": null
},
"Invocation": {
"version": null,
"applicationNumber": null,
"transactionId": null,
"applicationDate": null,
"decisionPoint": null,
"decisionService": null,
"responseStatus": null,
"error": {
"stackTrace": null,
"source": null,
"dateTime": null,
"errorCode": null,
"description": null
}
}
}
]
},
"STATUS": "SUCCESS"
}
Please help !
Regards,
Gaurav
{
"Header": {
"Source": "SFDC",
"UniqueId": "XXXXXX",
"Target": "ServiceName",
"DateTime": "2018-10-26 11:33:13"
},
"Detail": {
"ApplicationID": "xxx",
"BureauStatus": "Success",
"BureauError": {
"ErrorCode": null,
"ErrorMessage": null
},
"BureauResponse": [
{
"ApplicantID": null,
"ProcessedRequest": [
{
"@nil": "",
"BureauId": 11,
"BureauProduct": {
"@nil": "true",
"BureauId": null,
"CategoryAlias": null,
"IsALL": null,
"IsActive": null,
"IsEnquiryCreated": null,
"LOSId": null,
"Priority": null,
"ProductCode": {
"@nil": ""
},
"ProductId": null,
"ProductName": {
"@nil": ""
},
"RefNo": null,
"RuleIdList": {
"@nil": ""
}
},
"ConsumerName": {
"@nil": "true"
},
"Error": {
"@nil": "true"
},
"ErrorCode": {
"@nil": "true"
},
"ErrorDetail": {
"@nil": "true"
},
"ExistingRefNo": 0,
"LOSApplicationNo": {
"@nil": "",
"$": "XXXXXX"
},
"ProcessingTime": {
"@nil": "",
"$": "00:00:01.9591036"
},
"ReferenceNumber": 94717,
"ResponseType": "Normal",
"ResponseXML": {
"@nil": "",
"$": "<ResultBlock><MatchSummary matches=\"0\"><TotalMatchScore /></MatchSummary><ErrorWarnings><Errors errorCount=\"0\" /><Warnings warningCount=\"1\"><Warning><Number>102009</Number><Message>Match schemes not used</Message><Values><Value>317</Value><Value>318</Value><Value>676</Value><Value>64</Value><Value>138</Value><Value>141</Value><Value>142</Value><Value>145</Value></Values></Warning></Warnings></ErrorWarnings></ResultBlock>"
},
"Status": {
"@nil": "",
"$": "Finished"
},
"TimeOutStatus": {
"@nil": "",
"$": "NoHit"
},
"XMLFileName": {
"@nil": "true"
}
}
]
}
],
"BreStatus": "Error",
"BreError": {
"ErrorCode": "TW-001",
"ErrorMessage": "Evaluation error \nExpression produces unexpected value: Invalid index: 0.\nInvalid index: 0 while evaluating function fn_Definitions "
},
"BREResponse": [
{
"response": {
"systemDecision": null,
"systemDecisionDateTime": null,
"strategyUsed": null,
"finalApprovalLevel": null,
"policyRulesDecision": null,
"scoreDecision": null
},
"Invocation": {
"version": null,
"applicationNumber": null,
"transactionId": null,
"applicationDate": null,
"decisionPoint": null,
"decisionService": null,
"responseStatus": null,
"error": {
"stackTrace": null,
"source": null,
"dateTime": null,
"errorCode": null,
"description": null
}
}
}
]
},
"STATUS": "SUCCESS"
}
Please help !
Regards,
Gaurav
Following your XML input file example, I would use this code:
Does this make any sense?
Regards.