Skip to search.
phpexperts

Group Information

? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Messages

  Messages Help
Advanced
need array response in xml   Message List  
Reply Message #15429 of 15513 |
Re: need array response in xml



Saleha,
Its showing absolutely correct error message. Did you notice that you are
suppose to pass an object as a parameter on this function? If you are doing so
$xml should be an object already and IFF it is, then why are you using $xml (as
an object) in the preg_replace function as 3rd parameter? According to
preg_replace function the 3rd parameter should be anything but array and object.
Thats why its failing. Example:

Syntax definition for preg_replace:
mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int
$limit = -1 [, int &$count ]] )

So, the 3rd parameter generally has to be a string. Also notice that you are
returning the value of that line 224 into $xml back again. This is
programmatically correct, but do you think you are running out of variable
names? Use some other variable name here.

To make your function working, I think you do not need object to be passed onto
this function, you need pure xml as a string into this.

Hope you will understand your problem now.

Thanks
Yamin

--- In phpexperts@yahoogroups.com, Saleha Latif <salehalatif@...> wrote:
>
> The Function & error on line 224 i put double quotations as its has "/*" in
actual function it has single quotations.
>
>
> Catchable fatal error: Object of class stdClass could not be converted to
string in D:\wamp\www\booking\uapi\air_v16_0\test.php on line 224
>
>
> function formatXmlString($xml){
>
>   line 224 => $xml = preg_replace("/(>)(<)(\/*)/", "$1\n$2$3", $xml);
>     $token      = strtok($xml, "\n");
>     $result     = '';
>     $pad        = 0;
>     $matches    = array();
>     while ($token !== false) :
>         if (preg_match('/.+<\/\w[^>]*>$/', $token, $matches)) :
>           $indent=0;
>         elseif (preg_match('/^<\/\w/', $token, $matches)) :
>           $pad--;
>           $indent = 0;
>         elseif (preg_match('/^<\w[^>]*[^\/]>.*$/', $token, $matches)) :
>           $indent=1;
>         else :
>           $indent = 0;
>         endif;
>         $line    = str_pad($token, strlen($token)+$pad, ' ',
STR_PAD_LEFT);
>         $result .= $line . "\n";
>         $token   = strtok("\n");
>         $pad    += $indent;
>     endwhile;
>     return $result;
> }
>
>
>
> ________________________________
> From: shiplu <shiplu.net@...>
> To: phpexperts@yahoogroups.com
> Sent: Thursday, February 23, 2012 2:10 PM
> Subject: Re: [phpXperts] need array response in xml
>
>
>  
> It seems formatXmlStringfunction is failing. Are you sure this function takes
stdClassas parameter and returns string? Could you paste the function body
here?
>
>
> -- 
> Shiplu.Mokadd.im
> ImgSign.com | A dynamic signature machine
> Innovation distinguishes between follower and leader
>





Fri Feb 24, 2012 6:05 pm

ymnoor21
Offline Offline
Send Email Send Email

Message #15429 of 15513 |
Expand Messages Author Sort by Date

Hi, i have got a response of api which prints like : echo "<xmp>"; print_r($myResponse); echo "</xmp>"; It shows me result in array: stdClass Object (    ...
Saleha Latif
salehalatif Offline Send Email
Feb 23, 2012
6:42 am

It seems formatXmlString function is failing. Are you sure this function takes stdClass as parameter and returns string? Could you paste the function body...
shiplu
staticint Offline Send Email
Feb 23, 2012
10:15 am

The Function & error on line 224 i put double quotations as its has "/*" in actual function it has single quotations. Catchable fatal error: Object of class...
Saleha Latif
salehalatif Offline Send Email
Feb 24, 2012
6:50 am

Saleha, Its showing absolutely correct error message. Did you notice that you are suppose to pass an object as a parameter on this function? If you are doing...
ymnoor21 Offline Send Email Feb 24, 2012
8:33 pm
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help