Hello,
I am receiving the below response from the backend, could you please help me to extract the XML response out of it , as i need to convert that xml message to JSON and send to UI.
Response revived from Backend(Its not proper xml) :
<html> <head> <title>Gateway result</title> <body> <center> <h1>Gateway Result</h1> <p> <form method=get name=frmresult action="/SMSservice/servlet/Gateway"> <textarea rows=20 cols=60> <EmployeeDetails> <Name> <FName>Vinod</FName> </Name> </EmployeeDetails> </textarea> <p> <input type=button name=btnBack value="<< Back" onClick="history.go(-1)"> </form> </center> </body> </html>
I want to extract the EmployeeDetails out of above response and convert to JSON.
please help me to extract the employeedetails xml out of above response.
Thanks a lot in Advance.
Solved! Go to Solution.
If your xml not well formed then you can use a tool like JSoup which will do its best attempt to parse the XML or you can use regex and take advance of matching groups in a JavaScript policy.
var content='<html> <head> <title>Gateway result</title>...'; var firstName = content.match(/FName>(.*?)<\//)[1];
If your xml not well formed then you can use a tool like JSoup which will do its best attempt to parse the XML or you can use regex and take advance of matching groups in a JavaScript policy.
var content='<html> <head> <title>Gateway result</title>...'; var firstName = content.match(/FName>(.*?)<\//)[1];
Thank you Arelano, sure i will try with the option suggest.
Also in may case the backend is now able to send the proper XML provided if we send a flag specifying that proxy needs xml response.
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |