Portal Home > Knowledgebase > Articles Database > PHP performing on XML response


PHP performing on XML response




Posted by FinalFrontier, 11-22-2011, 03:35 AM
I send off this: In return, I get the following XML: Is there a way to make it so this does not show, and instead I can make PHP do something like: if (eTrxnStatus == True) {// do stuff}; ?

Posted by Squidix - SamBarrow, 11-22-2011, 05:04 AM
If you want to get the data back as a string instead of outputting it: curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); ... $output = curl_exec($ch); curl_close($ch); $data = simplexml_load_string($output);

Posted by FinalFrontier, 11-22-2011, 06:55 AM
Thank you, Sam. I will try that soon. What I am doing now is this... I'm using: ... but getting these errors: The response code I am getting back in XML is: What could be causing this? I can't make any sense of it at all!

Posted by Squidix - SamBarrow, 11-22-2011, 06:59 AM
Because curl_exec() does not return the string, it sends it to standard output. It's not returning anything, just printing, that's why you get "Start tag expected, '<' not found" meaning there is no data being passed to that function. That's why this is necessary: curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); This will cause curl_exec not to print the output, but to return it from the function so it can be put into a variable or passed to a function as you are attempting to do now.

Posted by FinalFrontier, 11-22-2011, 07:05 AM
Hah! You were so damn right! You actually solved both my problems in 1 go. Totally skilled Sam! Thank you very much! * shakes hand *

Posted by Squidix - SamBarrow, 11-22-2011, 07:08 AM
No problem.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
iptables not saving (Views: 736)
Longest pass of fsck? (Views: 707)


Language: