1

I have successfully completed an HTTP GET request using PHP and cURL. How do I extract a variable from the response?

Here is the response I am receiving:


<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://ws.example.com/resumes/">
  <Packet>
    <Errors />
    <SessionToken>1234567890</SessionToken>
  </Packet>
</string>

I need to extract the "1234567890" and set it as a PHP the $sessionid variable.

How can I do this?

2 Answers 2

2

Check out SimpleXML. It will be your best bet.

Sign up to request clarification or add additional context in comments.

Comments

1
$xml = new SimpleXMLElement($xmlstr);
echo $xml->Packet->SessionToken;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.