[phpxmlrpc] getting results from server ok but!
Jeff Barr
jeff at vertexdev.com
Sat Dec 20 23:15:17 GMT 2003
Here is how to take apart an array. Let's say that
the top-level return is a structure which contains
an array named 'thing_array' as a member, and that
the array contains scalars.
$Val = $result->value();
$ArrayMember = $Val->structmem('thing_array');
$ArrayCount = $ArrayMember->arraysize();
for ($i = 0; $i < $ArrayCount; $i++)
{
$ArrayVal = $ArrayMember->arraymem($i);
$ArrayItem = $ArrayVal->scalarval();
print("thing_array[$i] = $ArrayItem\n");
}
If you wanted to get really tricky, you could
deal with arrays of structures, arrays of
arrays, and so forth.
Jeff;
> Hi Jeff
>
> thanks for info, i am making progress.
>
> I think the structmem variety.
>
> first script http://www.mds.me.uk/xml-whois.php
>
> does call and simply uses print_r(get_object_vars($result)); to display
> $result.
>
> second script http://www.mds.me.uk/xml-whois-1.php
>
> uses
>
> $Val = $result->value();
> $domain = $Val->structmem("domain");
> $error = $Val->structmem("error");
> $found = $Val->structmem("found");
>
> and again print_r(get_object_vars($error) etc. with a couple of added
> markers to break up text.
>
> now all i need to do is decode the 3 objects so i can grab the items like
> 'address' etc.
> i guess these are nested Array's, any pointers
>
> Mark
>
> ----- Original Message -----
> From: "Jeff Barr" <jeff at vertexdev.com>
> To: "Obantec Support" <support at obantec.net>
> Cc: <phpxmlrpc at usefulinc.com>
> Sent: Friday, December 19, 2003 2:13 PM
> Subject: Re: [phpxmlrpc] getting results from server ok but!
>
>
>
>>Obantec Support wrote:
>>
>>
>>>i have put together a php script to access a whois server that uses xml.
>>>now i used their guides to send correct format of message but am lost as
>
> to
>
>>>how to use the response.
>>
>>You need to take the results apart using functions such as value,
>>scalarval, and structmem. If your function returned a single
>>value you would do something like this:
>>
>> $Val = $result->value();
>> $ScalarVal = $Val->scalarval();
>>
>>If it returned a structure with name and age members:
>>
>> $Val = $result->value();
>> $NameVal = $Val->structmem("name");
>> $AgeVal = $Val->structmem("age");
>> $Name = $NameVal->scalarval();
>> $Age = $AgeVal->scalarval();
>>
>>Make sense?
>>
>>Jeff;
>>
>>
>>>is there some function that parses the xml so i can access results.
>>>currently i am dumping to screen using
>>>
>>>$result = $client->send($message);// send request
>>>
>>>// error handler in here
>>>
>>>print_r(get_object_vars($result)); // show result to screen
>>>
>>>(i am new to both php and xml but have programmed in perl).
>>>
>>>Sorry if question is a bit OT, i was going to ask how to get results
>
> from
>
>>>server but googled my way thru my problems.
>>>
>>>Mark
>>>
>>>
>>>_______________________________________________
>>>phpxmlrpc mailing list
>>>phpxmlrpc at usefulinc.com
>>>http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
>>
>>
>
>
> _______________________________________________
> phpxmlrpc mailing list
> phpxmlrpc at usefulinc.com
> http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc
More information about the phpxmlrpc
mailing list