0

I'm calling an external site from Visualforce and it's returning me a response as below (i.e. HttpResponse.GetBody() returned sting).

<DtResponse RequestId="" ResultCount="1" ErrorMessage=""> <Result TemporaryKey="**SecretTempKeyValue***==" /> </DtResponse> 

I can read it by using string functions which is not a good method. I need to read this without using string functions. What is the best method to read the Temporary Key field in HTTP Response body?

Any help with a simple code example would be great. Thanks.

1
  • 1
    If the response is not in specific format then you have to read it through string function. If the response is in JSON or XML, you can use JASON parser or XML parser class.
    – MIX DML
    Dec 1, 2016 at 3:53

1 Answer 1

2

You can use getBodyDocument instead, which would look like this:

Dom.Document doc = response.getBodyDocument();
String tempKey = doc.getRootElement()
                  .getChildElement('Result', null)
                  .getAttribute('TemporaryKey', null);
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .