I am trying to convert json string to xml in c# and parse the data from acctNo and availBal node in the same.
But i am getting exception
JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifying a DeserializeRootElementName.
My json string is as below:
<pre>{
"results": [
{
"rimNo": "1220551",
"rimName": "YOGESH SHAH",
"rimType": "NonPersonal",
"rimStatus": "Active",
"rimClass": "Elite-High Networth Individual",
"acctNo": "AE590230000001005506660",
"acctTitle": "YOGESH SHAH",
"acctType": "CIA",
"acctStatus": "Active",
"acctClass": "CK-Elite-NIB-Res-AED",
"acctBrNo": "99",
"acctBranch": "Head Office",
"segment": "CBD Elite",
"availBal": "878.2900",
"currency": "AED",
"nationality": "India",
"phone1": "",
"phone2": "",
"mobile": "971507587623",
"email1": "YOGESH@EMAIL.COM",
"email2": "",
"ref": "REF20240501154316770",
"reserved1": "",
"reserved2": "",
"reserved3": ""
}
],
"errors": [
{
"errorCode": "000",
"errorMessage": "Success"
}
]
}
What I have tried:
My code isas below:
XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(json);