f



get IsValid boolean value from XML node

I'm trying to check for a valid result from the rest request XML
object in the "IsValid" item node.
It seems like it should work but I'm getting no value in $result and
the code gives me a result before I added this line:
if ($parsed_xml->Items->Request->IsValid["True"])
---PHP Code---
$request = file_get_contents("http://free.apisigning.com/onca/xml?".
$allparameter);
$parsed_xml = simplexml_load_string($request);

if ($parsed_xml->Items->Request->IsValid["True"]){
$result= $parsed_xml->Items->Item->ItemAttributes->ProductGroup;

$result= (string) $result;
var_dump($result);
}

The "IsValid" item is in the 2nd array in the XML object  below .  The
IsValid Item is after the 8th value in the 2nd array.  But there must
be something simple in this line this line I'm missing?
$parsed_xml->Items->Request->IsValid["True"]
I also tried
$parsed_xml->Items->IsValid["True"] &
 $parsed_xml->Items->Request->IsValid->True

array(2) {
  ["OperationRequest"]=>
  object(SimpleXMLElement)#2 (3) {
    ["RequestId"]=>
    string(36) "2577e416-7050-4f77-9762-70d880d50f80"
    ["Arguments"]=>
    object(SimpleXMLElement)#4 (1) {
      ["Argument"]=>
      array(9) {
        [0]=>
        object(SimpleXMLElement)#5 (1) {
          ["@attributes"]=>
          array(2) {
            ["Name"]=>
            string(9) "Operation"
            ["Value"]=>
            string(10) "ItemLookup"
          }
        }
        [1]=>
        object(SimpleXMLElement)#6 (1) {
          ["@attributes"]=>
          array(2) {
            ["Name"]=>
            string(7) "Service"
            ["Value"]=>
            string(19) "AWSECommerceService"
          }
        }
        [2]=>
        object(SimpleXMLElement)#7 (1) {
          ["@attributes"]=>
          array(2) {
            ["Name"]=>
            string(9) "Signature"
            ["Value"]=>
            string(44) "t9Q3sfHgREVtyk7jtL9xCHNVlmpUWdT1qNfmNiQA87Y="
          }
        }
        [3]=>
        object(SimpleXMLElement)#8 (1) {
          ["@attributes"]=>
          array(2) {
            ["Name"]=>
            string(7) "Version"
            ["Value"]=>
            string(10) "2009-01-06"
          }
        }
        [4]=>
        object(SimpleXMLElement)#9 (1) {
          ["@attributes"]=>
          array(2) {
            ["Name"]=>
            string(6) "ItemId"
            ["Value"]=>
            string(10) "B000VCKK02"
          }
        }
        [5]=>
        object(SimpleXMLElement)#10 (1) {
          ["@attributes"]=>
          array(1) {
            ["Name"]=>
            string(11) "IdType-ASIN"
          }
        }
        [6]=>
        object(SimpleXMLElement)#11 (1) {
          ["@attributes"]=>
          array(2) {
            ["Name"]=>
            string(14) "AWSAccessKeyId"
            ["Value"]=>
            string(20) "AKIAIETJLADYILLAACBA"
          }
        }
        [7]=>
        object(SimpleXMLElement)#12 (1) {
          ["@attributes"]=>
          array(2) {
            ["Name"]=>
            string(9) "Timestamp"
            ["Value"]=>
            string(20) "2010-05-08T22:35:18Z"
          }
        }
        [8]=>
        object(SimpleXMLElement)#13 (1) {
          ["@attributes"]=>
          array(2) {
            ["Name"]=>
            string(13) "ResponseGroup"
            ["Value"]=>
            string(5) "Small"
          }
        }
      }
    }
    ["RequestProcessingTime"]=>
    string(18) "0.0179210000000000"
  }
  ["Items"]=>
  object(SimpleXMLElement)#3 (2) {
    ["Request"]=>
    object(SimpleXMLElement)#14 (2) {
      ["IsValid"]=>
      string(4) "True"
      ["ItemLookupRequest"]=>
      object(SimpleXMLElement)#16 (10) {
        ["Condition"]=>
        string(3) "New"
        ["DeliveryMethod"]=>
        string(4) "Ship"
        ["IdType"]=>
        string(4) "ASIN"
        ["MerchantId"]=>
        string(6) "Amazon"
        ["OfferPage"]=>
        string(1) "1"
        ["ItemId"]=>
        string(10) "B000VCKK02"
        ["ResponseGroup"]=>
        string(5) "Small"
        ["ReviewPage"]=>
        string(1) "1"
        ["ReviewSort"]=>
        string(15) "-SubmissionDate"
        ["VariationPage"]=>
        string(3) "All"
      }
    }
    ["Item"]=>
    object(SimpleXMLElement)#15 (4) {
      ["ASIN"]=>
      string(10) "B000VCKK02"
      ["DetailPageURL"]=>
      string(201) "http://www.amazon.com/HoMedics-Professional-Doctors-
Scale/dp/B000VCKK02%3FSubscriptionId%3DAKIAIETJLADYILLAACBA%26tag%3Dws
%26linkCode%3Dxm2%26camp%3D2025%26creative%3D165953%26creativeASIN
%3DB000VCKK02"
      ["ItemLinks"]=>
      object(SimpleXMLElement)#17 (1) {
        ["ItemLink"]=>
        array(7) {
          [0]=>
          object(SimpleXMLElement)#19 (2) {
            ["Description"]=>
            string(17) "Technical Details"
            ["URL"]=>
            string(211) "http://www.amazon.com/HoMedics-Professional-
Doctors-Scale/dp/tech-data/B000VCKK02%3FSubscriptionId
%3DAKIAIETJLADYILLAACBA%26tag%3Dws%26linkCode%3Dxm2%26camp
%3D2025%26creative%3D386001%26creativeASIN%3DB000VCKK02"
          }
          [1]=>
          object(SimpleXMLElement)#20 (2) {
            ["Description"]=>
            string(20) "Add To Baby Registry"
            ["URL"]=>
            string(204) "http://www.amazon.com/gp/registry/baby/add-
item.html%3Fasin.0%3DB000VCKK02%26SubscriptionId%3DAKIAIETJLADYILLAACBA
%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative
%3D386001%26creativeASIN%3DB000VCKK02"
          }
          [2]=>
          object(SimpleXMLElement)#21 (2) {
            ["Description"]=>
            string(23) "Add To Wedding Registry"
            ["URL"]=>
            string(207) "http://www.amazon.com/gp/registry/wedding/add-
item.html%3Fasin.0%3DB000VCKK02%26SubscriptionId%3DAKIAIETJLADYILLAACBA
%26tag%3Dws%26linkCode%3Dxm2%26camp%3D2025%26creative
%3D386001%26creativeASIN%3DB000VCKK02"
          }
          [3]=>
          object(SimpleXMLElement)#22 (2) {
            ["Description"]=>
            string(15) "Add To Wishlist"
            ["URL"]=>
            string(208) "http://www.amazon.com/gp/registry/wishlist/
add-item.html%3Fasin.0%3DB000VCKK02%26SubscriptionId
%3DAKIAIETJLADYILLAACBA%26tag%3Dws%26linkCode%3Dxm2%26camp
%3D2025%26creative%3D386001%26creativeASIN%3DB000VCKK02"
          }
          [4]=>
          object(SimpleXMLElement)#23 (2) {
            ["Description"]=>
            string(13) "Tell A Friend"
            ["URL"]=>
            string(173) "http://www.amazon.com/gp/pdp/taf/
B000VCKK02%3FSubscriptionId%3DAKIAIETJLADYILLAACBA%26tag%3Dws
%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN
%3DB000VCKK02"
          }
          [5]=>
          object(SimpleXMLElement)#24 (2) {
            ["Description"]=>
            string(20) "All Customer Reviews"
            ["URL"]=>
            string(177) "http://www.amazon.com/review/product/
B000VCKK02%3FSubscriptionId%3DAKIAIETJLADYILLAACBA%26tag%3Dws
%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN
%3DB000VCKK02"
          }
          [6]=>
          object(SimpleXMLElement)#25 (2) {
            ["Description"]=>
            string(10) "All Offers"
            ["URL"]=>
            string(179) "http://www.amazon.com/gp/offer-listing/
B000VCKK02%3FSubscriptionId%3DAKIAIETJLADYILLAACBA%26tag%3Dws
%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN
%3DB000VCKK02"
          }
        }
      }
      ["ItemAttributes"]=>
      object(SimpleXMLElement)#18 (3) {
        ["Manufacturer"]=>
        string(8) "Homedics"
        ["ProductGroup"]=>
        string(7) "Kitchen"
        ["Title"]=>
        string(26) "Professional Doctors Scale"
      }
    }
  }
}

Thanks,
0
jr
5/9/2010 1:08:48 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

1 Replies
517 Views

Similar Articles

[PageSpeed] 23

On May 8, 6:08=A0pm, jr <jlro...@yahoo.com> wrote:
> I'm trying to check for a valid result from the rest request XML
> object in the "IsValid" item node.
> It seems like it should work but I'm getting no value in $result and
> the code gives me a result before I added this line:
> if ($parsed_xml->Items->Request->IsValid["True"])
> ---PHP Code---
> $request =3D file_get_contents("http://free.apisigning.com/onca/xml?".
> $allparameter);
> $parsed_xml =3D simplexml_load_string($request);
>
I got the answer through trial and error.
$parsed_xml->Items->IsValid =3D"True"

0
jr
5/10/2010 11:01:18 PM
Reply: