0

Hey guys im feeding a curl response into a simple xml object.

$xml = simplexml_load_string($redirect);

$xml.asXml() gets me this ->

<?xml version="1.0" encoding="UTF-8"?>
<checkout-redirect xmlns="http://checkout.google.com/schema/2" serial-number="9160aabc-  5efe-4f9e-bb90-71ce75d7815f">
<redirect-url>https://sandbox.google.com/checkout/view/buy?  o=shoppingcart&amp;shoppingcart=222826053769344</redirect-url>
</checkout-redirect>

when I do: $xml->redirect-url

ErrorException [ Notice ]: Use of undefined constant url - assumed 'url'
die(var_dump($xml->redirect-url));

shouldn't I be able to access it like this?

Charles
  • 50,943
  • 13
  • 104
  • 142
jr3
  • 915
  • 3
  • 14
  • 28

1 Answers1

1

Can you try $xml->{'redirect-url'} ?

I really don't know if that works, but you can give it a try :D

Thomas Menga
  • 1,858
  • 14
  • 17
  • "redirect-url" is an incorrect variable name (due to the "-"). – Thomas Menga Mar 22 '11 at 07:03
  • how do i get around that Leki? this is a response from google, so I have no ability to change it without crazy hacks.. and i dont wanna go down that road. – jr3 Mar 22 '11 at 07:09
  • `$xml->{'redirect-url'}` didn't work (instead of `$xml->redirect-url`) ? – Thomas Menga Mar 22 '11 at 07:10
  • this returns: object(SimpleXMLElement)#14 (1) { [0]=> string(88) "https://sandbox.google.com/checkout/view/buy?o=shoppingcart&shoppingcart=819902860469198" } – jr3 Mar 22 '11 at 07:11
  • hooray thanks! LekisS $this->request->redirect($xml->{'redirect-url'}); works perfect! – jr3 Mar 22 '11 at 07:14