Building PHP soapClient array not working
I have a successful soapClient that generates content from the following
XML sample
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<ActivityId
xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics"
CorrelationId="f62a50bd-af24-4719-acca-fcfb8770028d">ebc35110-673d-4d15-aacd-020e14a8d62b</ActivityId>
</s:Header>
<s:Body>
<GMDataResponse xmlns="http://xx.com/xx">
<GMDataResult xmlns:a="http://xx.com/xx/GMData"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Users>
<a:MData.UserData>
<a:ProjectId>37199</a:ProjectId>
<a:Name>Hilda Smith</a:Name>
<a:Number>101</a:Number>
<a:First>Hilda</a:First>
</a:MData.UserData>
<a:MData.UserData>
<a:ProjectId>37199</a:ProjectId>
<a:Name>John Smith</a:Name>
<a:Number>102</a:Number>
<a:First>John</a:First>
</a:MData.UserData>
I use the following to build the loop and it works:
$UsersAr = is_array( $res->GMDataResult->Users )
? $res->GMDataResult->Users
: array( $res->GMDataResult->Users );
foreach ($UsersAr as $Users) {
foreach($Users as $UserSet) {
foreach($UserSet as $u) {
echo $u->Name ."<br>";
}
}
}
I try:
foreach ($UsersAr as $users) {
$user = $users->MBData.UserData;
echo $user->Name;
}
and it fails (Notice: Undefined property: stdClass::$MBData) Seems like
the period in MBData.UserData is throwing an error? I'd like the cleanest
code since this is a high volume process.
No comments:
Post a Comment