解析xml数组不显示视图中的所有数据

时间:2015-09-22 07:29:26

标签: php arrays xml

我试图显示Ebay GetSingleItem响应(http://developer.ebay.com/devzone/shopping/docs/callref/GetSingleItem.html)并且我在显示数组[“ItemSpecifics”]时遇到问题。电话正常,我收到以下信息:

["ItemSpecifics"] => object(DTS\eBaySDK\Shopping\Types\NameValueListArrayType)#208 (2) {
          ["values":"DTS\eBaySDK\Types\BaseType":private] => array(1) {
            ["NameValueList"] => object(DTS\eBaySDK\Types\UnboundType)#129 (5) {
              ["data":"DTS\eBaySDK\Types\UnboundType":private] => array(8) {
                [0] => object(DTS\eBaySDK\Shopping\Types\NameValueListType)#207 (2) {
                  ["values":"DTS\eBaySDK\Types\BaseType":private] => array(2) {
                    ["Name"] => string(6) "Format"
                    ["Value"] => object(DTS\eBaySDK\Types\UnboundType)#191 (5) {
                      ["data":"DTS\eBaySDK\Types\UnboundType":private] => array(1) {
                        [0] => string(10) "DVD/HD-DVD"
                      }
                      ["position":"DTS\eBaySDK\Types\UnboundType":private] => int(0)
                      ["class":"DTS\eBaySDK\Types\UnboundType":private] => string(44) "DTS\eBaySDK\Shopping\Types\NameValueListType"
                      ["property":"DTS\eBaySDK\Types\UnboundType":private] => string(5) "Value"
                      ["expectedType":"DTS\eBaySDK\Types\UnboundType":private] => string(6) "string"
                    }
                  }
                  ["attachment":"DTS\eBaySDK\Types\BaseType":private] => array(2) {
                    ["data"] => NULL
                    ["mimeType"] => NULL
                  }
                }
                [1] => object(DTS\eBaySDK\Shopping\Types\NameValueListType)#65 (2) {
                  ["values":"DTS\eBaySDK\Types\BaseType":private] => array(2) {
                    ["Name"] => string(5) "Genre"
                    ["Value"] => object(DTS\eBaySDK\Types\UnboundType)#152 (5) {
                      ["data":"DTS\eBaySDK\Types\UnboundType":private] => array(1) {
                        [0] => string(16) "Sci-Fi & Fantasy"
                      }
                      ["position":"DTS\eBaySDK\Types\UnboundType":private] => int(0)
                      ["class":"DTS\eBaySDK\Types\UnboundType":private] => string(44) "DTS\eBaySDK\Shopping\Types\NameValueListType"
                      ["property":"DTS\eBaySDK\Types\UnboundType":private] => string(5) "Value"
                      ["expectedType":"DTS\eBaySDK\Types\UnboundType":private] => string(6) "string"
                    }
                  }
                  ["attachment":"DTS\eBaySDK\Types\BaseType":private] => array(2) {
                    ["data"] => NULL
                    ["mimeType"] => NULL
                  }
                }
                [2] => object(DTS\eBaySDK\Shopping\Types\NameValueListType)#180 (2) {
                  ["values":"DTS\eBaySDK\Types\BaseType":private] => array(2) {
                    ["Name"] => string(7) "Edition"
                    ["Value"] => object(DTS\eBaySDK\Types\UnboundType)#253 (5) {
                      ["data":"DTS\eBaySDK\Types\UnboundType":private] => array(1) {
                        [0] => string(10) "Widescreen"
                      }
                      ["position":"DTS\eBaySDK\Types\UnboundType":private] => int(0)
                      ["class":"DTS\eBaySDK\Types\UnboundType":private] => string(44) "DTS\eBaySDK\Shopping\Types\NameValueListType"
                      ["property":"DTS\eBaySDK\Types\UnboundType":private] => string(5) "Value"
                      ["expectedType":"DTS\eBaySDK\Types\UnboundType":private] => string(6) "string"
                    }

所以在我的控制器中我输入了以下信息:

$event = array();
            foreach($item->ItemSpecifics->NameValueList as $data){
                $event[] = $data;
            }

我使用:->setCollection($event)

设置数据

在我的html页面(视图)中我用过:

<?php $res = $this->getCollection() ?>
<?php foreach ($res as $row)
{
    echo "<tr id='0' class='0'>
                    <td>
                        <div class='name'>" . $row->Name . " </div>
                    </td>
                    <td>
                        <div class='value'>" . $row->Value . " </div>
                    </td>
                </tr>";
} ?>

但我的问题是只检索NAME中包含的数据。 Value中的信息不会被检索到视图中。只是为了更清楚地说明一个例子。显示信息= FORMAT但不显示DVD / HD-DVD。

["Name"] => string(6) "Format"
                        ["Value"] => object(DTS\eBaySDK\Types\UnboundType)#191 (5) {
                          ["data":"DTS\eBaySDK\Types\UnboundType":private] => array(1) {
                            [0] => string(10) "DVD/HD-DVD"
                          }

0 个答案:

没有答案