PHP - "注意:尝试获取非对象错误的属性"

时间:2016-06-04 05:04:04

标签: php xml

我得到了这个'注意:试图获取非对象错误的属性" ...

我目前有这个varDump:

2017-06-04T10:17:00+0530

这是我对xml elemtn的调用,它给出了错误:

object(SimpleXMLElement)#1 (1) {
  ["GetCompetitivePricingForASINResult"]=>
  object(SimpleXMLElement)#2 (2) {
    ["@attributes"]=>
    array(2) {
      ["ASIN"]=>
      string(10) "0747587086"
      ["status"]=>
      string(7) "Success"
    }
    ["Product"]=>
    object(SimpleXMLElement)#3 (1) {
      ["Identifiers"]=>
      object(SimpleXMLElement)#4 (1) {
        ["MarketplaceASIN"]=>
        object(SimpleXMLElement)#5 (2) {
          ["MarketplaceId"]=>
          string(13) "ATVPDKIKX0DER"
          ["ASIN"]=>
          string(10) "0747587086"
        }
      }
    }
  }
}

有人可以建议我需要做什么吗?我在网上做了一些研究;但似乎具体案例......

谢谢,

2 个答案:

答案 0 :(得分:4)

您跳过了Product,而您在s末尾遗漏了Identifiers。它应该是

$xmlFile->GetCompetitivePricingForASINResult->Product->Identifiers->MarketplaceASIN->ASIN

答案 1 :(得分:0)

看起来需要$xmlFile->GetCompetitivePricingForASINResult->Product->Identifiers->MarketplaceASIN->ASIN