Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何用php解析易趣xml响应_Php_Xml - Fatal编程技术网

如何用php解析易趣xml响应

如何用php解析易趣xml响应,php,xml,Php,Xml,我试图用php解析ebay对FindingItemAPI的XML响应。这是我的密码: 它无声地失败,没有任何错误。我确实打开了错误报告 非常感谢任何帮助 ---编辑--- XML代码响应的结构如下所示: <!--?xml version='1.0' encoding='UTF-8'?--> <finditemsadvancedresponse xmlns="http://www.ebay.com/marketplace/search/v1/services"> <

我试图用php解析ebay对FindingItemAPI的XML响应。这是我的密码:

它无声地失败,没有任何错误。我确实打开了错误报告

非常感谢任何帮助

---编辑---

XML代码响应的结构如下所示:

<!--?xml version='1.0' encoding='UTF-8'?-->
<finditemsadvancedresponse xmlns="http://www.ebay.com/marketplace/search/v1/services">
<ack>Success</ack>
<version>1.13.0</version>
<timestamp>2016-08-18T19:25:06.303Z</timestamp>
<searchresult count="1">
  <item>
    <itemid>123456789</itemid>
    <title>Item Title</title>
    <globalid>EBAY-US</globalid>
    <primarycategory>
      <categoryid>12345</categoryid>
      <categoryname>Category Name</categoryname>
    </primarycategory>
    <galleryurl>Galery URL</galleryurl>
    <viewitemurl>Item URL</viewitemurl>
    <paymentmethod>PayPal</paymentmethod>
    <autopay>false</autopay>
    <postalcode>12345</postalcode>
    <location>Location</location>
    <country>US</country>
    <shippinginfo>
      <shippingservicecost currencyid="USD">0.0</shippingservicecost>
      <shippingtype>Free</shippingtype>
      <shiptolocations>US</shiptolocations>
      <expeditedshipping>true</expeditedshipping>
      <onedayshippingavailable>false</onedayshippingavailable>
      <handlingtime>1</handlingtime>
    </shippinginfo>
    <sellingstatus>
      <currentprice currencyid="USD">15.99</currentprice>
      <convertedcurrentprice currencyid="USD">15.99</convertedcurrentprice>
      <sellingstate>Active</sellingstate>
      <timeleft>P9DT3H29M13S</timeleft></sellingstatus>
      <listinginfo>
        <bestofferenabled>false</bestofferenabled>
        <buyitnowavailable>false</buyitnowavailable>
        <starttime>2015-12-01T22:54:19.000Z</starttime>
        <endtime>2016-08-27T22:54:19.000Z</endtime>
        <listingtype>FixedPrice</listingtype>
        <gift>false</gift>
      </listinginfo>
      <returnsaccepted>true</returnsaccepted>
      <condition>
        <conditionid>3000</conditionid>
        <conditiondisplayname>Used</conditiondisplayname>
      </condition>
      <ismultivariationlisting>false</ismultivariationlisting>
      <topratedlisting>false</topratedlisting>
  </item>
</searchresult>
<paginationoutput>
  <pagenumber>1</pagenumber>
  <entriesperpage>1</entriesperpage>
  <totalpages>100</totalpages>
  <totalentries>100</totalentries>
</paginationoutput>
<itemsearchurl>http://www.ebay.com/sch/i.html?_sasl=allkillerdeals&amp;_saslop=1&amp;_fss=1&amp;LH_SpecificSeller=1&amp;_nkw=knife&amp;_ddo=1&amp;_ipg=1&amp;_pgn=1</itemsearchurl>
</finditemsadvancedresponse>

成功
1.13.0
2016-08-18T19:25:06.303Z
123456789
项目名称
易趣美国
12345
类别名称
Galery URL
项目URL
贝宝
假的
12345
位置
美国
0
自由的
美国
真的
假的
1.
15.99
15.99
活跃的
P9DT3H29M13S
假的
假的
2015-12-01T22:54:19.000Z
2016-08-27T22:54:19.000Z
固定价格
假的
真的
3000
使用
假的
假的
1.
1.
100
100
http://www.ebay.com/sch/i.html?_sasl=allkillerdeals&_萨斯洛普=1&_fss=1&;LH_Specific Seller=1&_nkw=刀和刀_ddo=1&_ipg=1&_pgn=1

终于破解了它。经过数小时的挫折,终于发现xml回送路径是区分大小写的。只发生在实际的脚本中,因为当我从html源代码复制xml(对于上面的示例)时,它显示为所有小写。但实际返回的xml在xml节点中的情况好坏参半

所以

需要:

    echo $xmlResponse -> searchResult -> item[0] -> title;

终于破解了。经过数小时的挫折,终于发现xml回送路径是区分大小写的。只发生在实际的脚本中,因为当我从html源代码复制xml(对于上面的示例)时,它显示为所有小写。但实际返回的xml在xml节点中的情况好坏参半

所以

需要:

    echo $xmlResponse -> searchResult -> item[0] -> title;

您必须显示实际的/相关的XML。如果没有它,php本身是无用的。您可以发布响应的样子吗?您应该能够使用自己的ebay凭据运行php来获得响应。我无法更改xml响应,它原样来自易趣。@TK421只需以易趣的响应为例-删除任何个人信息,并将其发布在此处即可。你不会得到答案,但是要求人们用他们自己的身份证来尝试这个请求。我们只是要求你给出答案。根据需要隐藏敏感信息。echo语句中指定的路径可能不正确。不要让我们志愿者承担获取API和按原样运行代码的负担。您必须显示实际的/相关的XML。如果没有它,php本身是无用的。您可以发布响应的样子吗?您应该能够使用自己的ebay凭据运行php来获得响应。我无法更改xml响应,它原样来自易趣。@TK421只需以易趣的响应为例-删除任何个人信息,并将其发布在此处即可。你不会得到答案,但是要求人们用他们自己的身份证来尝试这个请求。我们只是要求你给出答案。根据需要隐藏敏感信息。echo语句中指定的路径可能不正确。不要让我们的志愿者承担获取API和按原样运行代码的负担。但是您发布的XML具有
searchresult
所有小写字母,而不是camelcase。它确实。。。我从页面上的html源代码中复制了它,使其全部小写。直到我把它打印到一个文本区,并将其与ebay api文档中的响应结构进行比较,我才意识到它是camelcase。但您发布的XML具有
searchresult
所有小写字母,而不是camelcase。它确实。。。我从页面上的html源代码中复制了它,使其全部小写。直到我把它打印到一个文本区,并将其与ebay api文档中的响应结构进行比较,我才意识到它是camelcase。
    echo $xmlResponse -> searchresult -> item[0] -> title;
    echo $xmlResponse -> searchResult -> item[0] -> title;