Re: Newbie Question - Parse XML with PHP...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This will be brief as I'm on a tablet...

On Apr 19, 2013 5:53 PM, "dealTek" <dealtek@xxxxxxxxx> wrote:
>
>
> On Apr 19, 2013, at 3:32 PM, tamouse mailing lists <
tamouse.lists@xxxxxxxxx> wrote:
>
> >>
> >> page1.php is sending out to credit card company - getting processed -
then coming back to the *same page1.php* with the XML data listed below...
> >
> > Please expand what you mean by "sending out" and "coming back" - is
> > this a REST or SOAP API call? In that case, the response body is
> > likely to be the XML.
> >
> >>
> >> - so I'm not going to some other page to get it - it is coming to me
to the same page I am on..........
> >>
> >> so - after the XML result comes in - I need to assign the php to the
XML somehow...
> >
> > How do you recognize the "XML result com(ing) in" ?
> >
>
> Hi tamouse,
>
> with my untrained eye - it appears that this  is what is 'sending out'
>
>
>  $data = sendXMLviaCurl($xmlRequest,$gatewayURL);

This is the  sending and receiving -- the function uses curl to send your
xml request and returns the response from that.

>
>
> and this might be what is 'responding back' on the same page
>
>
>     $gwResponse = @new SimpleXMLElement((string)$data);

$data contains the response, this is how you are processing it.

Skipping the long and monolithic code, what I will suggest is that you
break things up into modules, functions and procrdures, and write unit
tests that will check each piece seperately. After you've verified that
each step is working, then you can start to integrate the pieces, following
the stricture of keeping code (logic), data, and presentation seperate.

It is much easier to deal with debugging when your code is simple and does
only one thing. Break out the part you are asking here about, the API call.
Build up a viable test request that will get you a known response and make
sure you are getting what you expect. My suspicion is that the response
here isnot what you expect.

>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux