troubleshooting Question

php Curl XML reponse - how do I get the three values out of the xml parsable html string:

Avatar of mavmanau
mavmanauFlag for Australia asked on
HTMLPHPXML
10 Comments1 Solution486 ViewsLast Modified:
Hi,

Many thanks for your assistance it is appreciated.  Essentially I am uploading some data and getting a reponse back.

This is my current code for uploading.

$ch = curl_init( $url );
  ini_set('display_errors', 'On');
error_reporting(E_ALL);
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec( $ch );
curl_close($ch);
 
  //Parse the XML
  $phpobject = simplexml_load_string($response);
 
  foreach($phpobject->attributes() as $name=>$attr) {
    $res[$name]=$attr;
  }
  print_r($phpobject);
 // $PaymentDataResponse = new SimpleXMLElement($response);
 // echo $PaymentDataResponse->PaymentURL;
?>

and this is the response:

SimpleXMLElement Object ( [body] => SimpleXMLElement Object ( [form] => SimpleXMLElement Object ( [input] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [type] => hidden [name] => SessionStored [value] => True ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [type] => hidden [name] => SessionStoredError [value] => ) ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [type] => hidden [name] => SST [value] => f39796a6-bf4c-451a-9d07-acfe2e3e51ad ) ) ) ) ) )

How do I go about extracting just the SST and the SessionStored and the SessionStorederror instead of the whole lot.

your help is most appreciated.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros