After sending a request to a webserver in python, I received XML code and I applied few changes on it
import re
s='<?xml version="1.0" encoding="utf-8"?><string xmlns="http://emts.erpguru.in/">{"data":[{"Id":0,"IsSuccess":true,"Msg":"MobileNo Already Exists"}] }</string>'
result = re.search('"data":\[{(.*?)}', s)
j= (result.group(1)).split(',')
print(j[2])
output : "Msg":"MobileNo Already Exists"
I need a more efficient way to convert XML result into an array, so that
print(j[“Msg”])
would give result
MobileNo Already Exists
import jsonandjson.loads(some_string)), as your string contains JSON nested in XML.