0

我调用commission junction API 并将其作为响应接收。

$xml_response = simplexml_load_file($xml_response);
exit($xml_response);

如果我做

  $xml = new SimpleXMLElement($xml_response);

我收到应用程序错误。(不知道如何找到这是什么错误,我可以在哪里设置错误代码以显示这部分?)

Warning: simplexml_load_file(): I/O warning : failed to load external entity " 106032782478435B & H Photo VideoComputers & Solutions > Laptops > MacBookshttp://www.jdoqocy.com/click-4107027-10603278?url=http://www.bhphotovideo.com/c/product/871865-REG/Apple_MD101LL_A_13_3_MacBook_Pro_Notebook.html/kw/APMBPMD101LL&cjsku=APMBPMD101LLcjo:6USDApple 13.3" MacBook Pro Notebook Computer, Intel Core i5 Dual-Core 2.5 GHz CPU, Internal 4GB DDR3 RAM, Features 500GB 5400 RPM Hard Drive, Intel HD 4000 Graphics, LED-Backlit 13.3" (33.8 cm) Display, Native 1280 x 800 Resolution, Wireless 802.11n WiFi & Bluetooth 4.0, Dual USB 3.0 Ports & Thunderbolt Port, Ships with Mac OS X Lion, Free OS X in /var/www/html/site.net/beta/library/API/CommissionJunction.php on line 119

** 更新 **

完整的 XML 响应:

string(9582) "<?xml version="1.0" encoding="UTF-8"?>
<cj-api><products total-matched="5" records-returned="5" page-number="1"><product><ad-id>10603278</ad-id><advertiser-id>2478435</advertiser-id><advertiser-name>B &amp; H Photo Video</advertiser-name><advertiser-category>Computers &amp; Solutions &gt; Laptops &gt; MacBooks</advertiser-category><buy-url>http://www.kqzyfj.com/click-4107027-10603278?url=http://www.bhphotovideo.com/c/product/871865-REG/Apple_MD101LL_A_13_3_MacBook_Pro_Notebook.html/kw/APMBPMD101LL&amp;cjsku=APMBPMD101LL</buy-url><catalog-id>cjo:6</catalog-id><currency>USD</currency><description>Apple 13.3" MacBook Pro Notebook Computer, Intel Core i5 Dual-Core 2.5 GHz CPU, Internal 4GB DDR3 RAM, Features 500GB 5400 RPM Hard Drive, Intel HD 4000 Graphics, LED-Backlit 13.3" (33.8 cm) Display, Native 1280 x 800 Resolution, Wireless 802.11n WiFi &amp; Bluetooth 4.0, Dual USB 3.0 Ports &amp; Thunderbolt Port, Ships with Mac OS X Lion, Free OS X Mountain Lion Upgrade MacBook Pro MacBook 13.3" MacBook Pro Notebook Computer</description><image-url>http://www.bhphotovideo.com/images/items/871865.jpg</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>Apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>Apple 13.3" MacBook Pro Notebook Computer</name><price>1139.0</price><retail-price>0.0</retail-price><sale-price>0.0</sale-price><sku>APMBPMD101LL</sku><upc>885909582969</upc></product><product><ad-id>10273684</ad-id><advertiser-id>242732</advertiser-id><advertiser-name>MacMall Affiliate Advantage Network</advertiser-name><advertiser-category>Systems &gt; MacBook Pro &gt; MacBook Pro w/ Intel Core i5 Processor &gt; 2.53 GHz MacBook Pro Computers</advertiser-category><buy-url>http://www.jdoqocy.com/click-4107027-10273684?url=http://www.macmall.com/p/7628870?dpno=9232227&source=zwb12166&amp;cjsku=9232227</buy-url><catalog-id>cjo:535</catalog-id><currency>USD</currency><description>2.5GHz dual-core Intel Core i5  Turbo Boost up to 3.1GHz  4GB 1600MHz memory  13.3" LED-backlit glossy widescreen display  Bluetooth 4.0  720p FaceTime camera  USB 3.0  Thunde</description><image-url>http://image1.cc-inc.com/prod/9232000/9232227_xlg.jpg</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>Apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>13.3 MacBook Pro dual-core Intel Core i5 2.5GHz  4GB RAM  500GB 5400-rpm hard drive  Intel HD Graphics 4000  Mac OS X Lion</name><price>1138.94</price><retail-price>1199.0</retail-price><sale-price>0.0</sale-price><sku>9232227</sku><upc>885909582969</upc></product><product><ad-id>10541923</ad-id><advertiser-id>2326608</advertiser-id><advertiser-name>Music123</advertiser-name><advertiser-category>Pro Audio/Computers &amp; Peripherals/Mac Computers/Notebook Mac Computers</advertiser-category><buy-url>http://www.dpbolvw.net/click-4107027-10541923?url=http://www.music123.com/pro-audio/apple-macbook-pro-13-2.5ghz-dual-core-i5-md101ll-a/h86479000000000&amp;cjsku=H86479</buy-url><catalog-id>cjo:2321</catalog-id><currency>USD</currency><description>One would think that it would be hard to improve on a great line of products, but year after year the team at Apple find a way, and they have added some powerful features to the next-generation of their MacBook Pro line of laptops. This 13 MacBook Pro (MD101LL/A) has everything youve ever looked for in an Apple computer, plus a whole lot more. Extremely fast processor upgrades, integrated HD graphics, super fast hard drive storage, USB 3.0 connections, and more. This generation of the MacBook Pro is ready for high-level performance. Top-of-the-line processors.The 13-inch model also speeds things up with either the 2.5GHz Intel Core i5 or the 2.9GHz Intel Core i7  the fastest mobile dual-core processor available. With Turbo Boost speeds up to 3.6GHz, these processors bring more power to everything you do. Learn more about processor performanceThe very latest graphics.The new integrated Intel HD Graphics 4000 processor boosts performance by up to 60 percent. That extra power gives you a smoother, more fluid experience than before. Its still highly efficient, too, so you get long battery life when youre out and about.The fastest, most versatile I/O in a notebook.Imagine accessing multiple streams of uncompressed HD video  from your MacBook Pro  at speeds that let you edit an HD feature film in real time. Thunderbolt technology allows you to connect the high-performance peripherals that make it possible. Ultrafast and ultra flexible, the Thunderbolt pipeline is up to 12 times faster than FireWire 800 and offers unprecedented expansion capabilities.FaceTime HD camera. Say hi in high def.Get more of your friends in on the fun with crisp, widescreen HD video. The picture is so clear, it will look and feel almost like youre in the same room. You can make 720p HD calls from your MacBook Pro to any Mac with a FaceTime HD camera. You can also make video calls to iPad, iPhone 4, iPhone 4S, iPod touch, and other Intel-based Mac computers.Multi-Touch trackpad. Be more hands-on.The Multi-Touch trackpad is the most natural way to interact with whats on your screen, and the smooth glass surface gives you plenty of room for gestures. Pinch to zoom in and out, swipe to flip through photos, rotate to adjust an image, and much more. The buttonless design lets you click anywhere. And if youre coming from a right-click world, you can right-click with two fingers or configure a right-click area on the trackpad. The more you use the Multi-Touch trackpad, the more youll wonder how you ever did without it.A long-lasting battery. Charge less. Do more.MacBook Pro delivers amazing battery life. And thats with more powerful processors and faster graphics than ever. An energy-efficient processor architecture with an integrated video encoder, along with automatic graphics switching in the 15-inch model, helps improve battery life. So you can get up to 7 hours on a single charge.Its very well connected.MacBook Pro automatically finds available networks and allows you to join them</description><image-url>http://static.music123.com/img/brand/m123/cmn/imagecomingsoon.gif</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>Apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>Apple MacBook Pro 13" 2.5GHz Dual-Core i5 (MD101LL/A)</name><price>1199.0</price><retail-price>1199.0</retail-price><sale-price>0.0</sale-price><sku>H86479</sku><upc>885909582969</upc></product><product><ad-id>10474050</ad-id><advertiser-id>2045991</advertiser-id><advertiser-name>Best Buy</advertiser-name><advertiser-category>Computing-LaptopsandNetbooks</advertiser-category><buy-url>http://www.kqzyfj.com/click-4107027-10474050?url=http://www.bestbuy.com/site/Apple%AE+-+MacBook%AE+Pro+-+13.3%22+Display+-+4GB+Memory+-+500GB+Hard+Drive/5430505.p?id=1218646127726&skuId=5430505&cmp=RMX&ky=2oh0NrwOl4j1qjMx3Oy2gXfVGhMUl0WiJ&ci_src=11138&ci_sku=5430505&amp;cjsku=5430505</buy-url><catalog-id>cjo:1791</catalog-id><currency>USD</currency><description>MacBook Pro features Intel's new third-generation Core architecture for a boost in processor and memory speeds. New next-generation graphicsdeliver performance levels that are up to 60 percent faster than before. And high-speed Thunderbolt I/O lets you transfer data at rates up to10 GBps. The MacBook Pro is a great computer that just got even greater.</description><image-url>http://images.bestbuy.com/BestBuy_US/images/products/5430/5430505_sc.jpg</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>Apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>Apple - MacBook Pro - 133" Display - 4GB Memory - 500GB Hard Drive</name><price>1199.99</price><retail-price>0.0</retail-price><sale-price>1199.99</sale-price><sku>5430505</sku><upc>885909582969</upc></product><product><ad-id>10479833</ad-id><advertiser-id>2014561</advertiser-id><advertiser-name>Apple Store US &amp; Apple Store Canada</advertiser-name><advertiser-category>Family : Macbook_Pro</advertiser-category><buy-url>http://www.kqzyfj.com/click-4107027-10479833?url=http://store.apple.com/us/xc/product/MD101LL/A?cid=AOS-US-AFF-FEED&aosid=p201&amp;cjsku=MD101</buy-url><catalog-id>cjo:1861</catalog-id><currency>USD</currency><description>The fastest Intel processors.       Now topping top speed.       MacBook Pro features Intel's new third-generation Core architecture, which boosts the speed of the processor and memory. And that means you have one powerful notebook on your hands. 50 percent faster graphics.       You'll be impressed. Instantly.       The 15-inch MacBook Pro features new discrete NVIDIA graphics that are up to 50 percent faster than before. New integrated Intel graphics also perform up to 50 percent faster. Thunderbolt and USB 3       I/O that sets new standards.       Thunderbolt technology lets you connect multiple high-performance devices to a single port - with data transfer rates up to 10 Gbps. Two new USB 3 ports are up to 10x faster than USB 2.</description><image-url>http://store.storeimages.cdn-apple.com/2782/as-images.apple.com/is/image/AppleInc/MC700</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>Apple MacBook Pro 13&amp;quot; 2.5GHz (MD101LL/A) - Dual Core Intel Core i5, 2.5GHz, 4GB memory, 500GB hard drive, 13-inch</name><price>1199.0</price><retail-price>0.0</retail-price><sale-price>0.0</sale-price><sku>MD101</sku><upc>885909582969</upc></product></products></cj-api>"
4

2 回答 2

1

我假设您使用的是 SimpleXML。

这部分永远不会起作用:$item->cj-api->, - 是一个运算符。如果您使用的是 SimpleXML,请尝试{'cj-api'}.

更核心的问题是$item->cj-api因为没有 cj-api 元素存在,所以它不起作用。那是不需要处理的根节点。请参阅http://www.php.net/manual/en/simplexml.examples-basic.php中的示例

于 2012-08-21T10:10:54.557 回答
1

您的 XML 格式不正确。

尝试解析 XML 时,buy-url元素包含无效内容。

XML Parsing Error: not well-formed
Location: file://///cc-fs1/users$/gavin.roberts/Desktop/Noname1.xml
Line Number 2, Column 1793:<cj-api><products total-matched="5" records-returned="5" page-number="1"><product><ad-id>10603278</ad-id><advertiser-id>2478435</advertiser-id><advertiser-name>B &amp; H Photo Video</advertiser-name><advertiser-category>Computers &amp; Solutions &gt; Laptops &gt; MacBooks</advertiser-category><buy-url>http://www.kqzyfj.com/click-4107027-10603278?url=http://www.bhphotovideo.com/c/product/871865-REG/Apple_MD101LL_A_13_3_MacBook_Pro_Notebook.html/kw/APMBPMD101LL&amp;cjsku=APMBPMD101LL</buy-url><catalog-id>cjo:6</catalog-id><currency>USD</currency><description>Apple 13.3" MacBook Pro Notebook Computer, Intel Core i5 Dual-Core 2.5 GHz CPU, Internal 4GB DDR3 RAM, Features 500GB 5400 RPM Hard Drive, Intel HD 4000 Graphics, LED-Backlit 13.3" (33.8 cm) Display, Native 1280 x 800 Resolution, Wireless 802.11n WiFi &amp; Bluetooth 4.0, Dual USB 3.0 Ports &amp; Thunderbolt Port, Ships with Mac OS X Lion, Free OS X Mountain Lion Upgrade MacBook Pro MacBook 13.3" MacBook Pro Notebook Computer</description><image-url>http://www.bhphotovideo.com/images/items/871865.jpg</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>Apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>Apple 13.3" MacBook Pro Notebook Computer</name><price>1139.0</price><retail-price>0.0</retail-price><sale-price>0.0</sale-price><sku>APMBPMD101LL</sku><upc>885909582969</upc></product><product><ad-id>10273684</ad-id><advertiser-id>242732</advertiser-id><advertiser-name>MacMall Affiliate Advantage Network</advertiser-name><advertiser-category>Systems &gt; MacBook Pro &gt; MacBook Pro w/ Intel Core i5 Processor &gt; 2.53 GHz MacBook Pro Computers</advertiser-category><buy-url>http://www.jdoqocy.com/click-4107027-10273684?url=http://www.macmall.com/p/7628870?dpno=9232227&source=zwb12166&amp;cjsku=9232227</buy-url><catalog-id>cjo:535</catalog-id><currency>USD</currency><description>2.5GHz dual-core Intel Core i5  Turbo Boost up to 3.1GHz  4GB 1600MHz memory  13.3" LED-backlit glossy widescreen display  Bluetooth 4.0  720p FaceTime camera  USB 3.0  Thunde</description><image-url>http://image1.cc-inc.com/prod/9232000/9232227_xlg.jpg</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>Apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>13.3 MacBook Pro dual-core Intel Core i5 2.5GHz  4GB RAM  500GB 5400-rpm hard drive  Intel HD Graphics 4000  Mac OS X Lion</name><price>1138.94</price><retail-price>1199.0</retail-price><sale-price>0.0</sale-price><sku>9232227</sku><upc>885909582969</upc></product><product><ad-id>10541923</ad-id><advertiser-id>2326608</advertiser-id><advertiser-name>Music123</advertiser-name><advertiser-category>Pro Audio/Computers &amp; Peripherals/Mac Computers/Notebook Mac Computers</advertiser-category><buy-url>http://www.dpbolvw.net/click-4107027-10541923?url=http://www.music123.com/pro-audio/apple-macbook-pro-13-2.5ghz-dual-core-i5-md101ll-a/h86479000000000&amp;cjsku=H86479</buy-url><catalog-id>cjo:2321</catalog-id><currency>USD</currency><description>One would think that it would be hard to improve on a great line of products, but year after year the team at Apple find a way, and they have added some powerful features to the next-generation of their MacBook Pro line of laptops. This 13 MacBook Pro (MD101LL/A) has everything youve ever looked for in an Apple computer, plus a whole lot more. Extremely fast processor upgrades, integrated HD graphics, super fast hard drive storage, USB 3.0 connections, and more. This generation of the MacBook Pro is ready for high-level performance. Top-of-the-line processors.The 13-inch model also speeds things up with either the 2.5GHz Intel Core i5 or the 2.9GHz Intel Core i7  the fastest mobile dual-core processor available. With Turbo Boost speeds up to 3.6GHz, these processors bring more power to everything you do. Learn more about processor performanceThe very latest graphics.The new integrated Intel HD Graphics 4000 processor boosts performance by up to 60 percent. That extra power gives you a smoother, more fluid experience than before. Its still highly efficient, too, so you get long battery life when youre out and about.The fastest, most versatile I/O in a notebook.Imagine accessing multiple streams of uncompressed HD video  from your MacBook Pro  at speeds that let you edit an HD feature film in real time. Thunderbolt technology allows you to connect the high-performance peripherals that make it possible. Ultrafast and ultra flexible, the Thunderbolt pipeline is up to 12 times faster than FireWire 800 and offers unprecedented expansion capabilities.FaceTime HD camera. Say hi in high def.Get more of your friends in on the fun with crisp, widescreen HD video. The picture is so clear, it will look and feel almost like youre in the same room. You can make 720p HD calls from your MacBook Pro to any Mac with a FaceTime HD camera. You can also make video calls to iPad, iPhone 4, iPhone 4S, iPod touch, and other Intel-based Mac computers.Multi-Touch trackpad. Be more hands-on.The Multi-Touch trackpad is the most natural way to interact with whats on your screen, and the smooth glass surface gives you plenty of room for gestures. Pinch to zoom in and out, swipe to flip through photos, rotate to adjust an image, and much more. The buttonless design lets you click anywhere. And if youre coming from a right-click world, you can right-click with two fingers or configure a right-click area on the trackpad. The more you use the Multi-Touch trackpad, the more youll wonder how you ever did without it.A long-lasting battery. Charge less. Do more.MacBook Pro delivers amazing battery life. And thats with more powerful processors and faster graphics than ever. An energy-efficient processor architecture with an integrated video encoder, along with automatic graphics switching in the 15-inch model, helps improve battery life. So you can get up to 7 hours on a single charge.Its very well connected.MacBook Pro automatically finds available networks and allows you to join them</description><image-url>http://static.music123.com/img/brand/m123/cmn/imagecomingsoon.gif</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>Apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>Apple MacBook Pro 13" 2.5GHz Dual-Core i5 (MD101LL/A)</name><price>1199.0</price><retail-price>1199.0</retail-price><sale-price>0.0</sale-price><sku>H86479</sku><upc>885909582969</upc></product><product><ad-id>10474050</ad-id><advertiser-id>2045991</advertiser-id><advertiser-name>Best Buy</advertiser-name><advertiser-category>Computing-LaptopsandNetbooks</advertiser-category><buy-url>http://www.kqzyfj.com/click-4107027-10474050?url=http://www.bestbuy.com/site/Apple%AE+-+MacBook%AE+Pro+-+13.3%22+Display+-+4GB+Memory+-+500GB+Hard+Drive/5430505.p?id=1218646127726&skuId=5430505&cmp=RMX&ky=2oh0NrwOl4j1qjMx3Oy2gXfVGhMUl0WiJ&ci_src=11138&ci_sku=5430505&amp;cjsku=5430505</buy-url><catalog-id>cjo:1791</catalog-id><currency>USD</currency><description>MacBook Pro features Intel's new third-generation Core architecture for a boost in processor and memory speeds. New next-generation graphicsdeliver performance levels that are up to 60 percent faster than before. And high-speed Thunderbolt I/O lets you transfer data at rates up to10 GBps. The MacBook Pro is a great computer that just got even greater.</description><image-url>http://images.bestbuy.com/BestBuy_US/images/products/5430/5430505_sc.jpg</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>Apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>Apple - MacBook Pro - 133" Display - 4GB Memory - 500GB Hard Drive</name><price>1199.99</price><retail-price>0.0</retail-price><sale-price>1199.99</sale-price><sku>5430505</sku><upc>885909582969</upc></product><product><ad-id>10479833</ad-id><advertiser-id>2014561</advertiser-id><advertiser-name>Apple Store US &amp; Apple Store Canada</advertiser-name><advertiser-category>Family : Macbook_Pro</advertiser-category><buy-url>http://www.kqzyfj.com/click-4107027-10479833?url=http://store.apple.com/us/xc/product/MD101LL/A?cid=AOS-US-AFF-FEED&aosid=p201&amp;cjsku=MD101</buy-url><catalog-id>cjo:1861</catalog-id><currency>USD</currency><description>The fastest Intel processors.       Now topping top speed.       MacBook Pro features Intel's new third-generation Core architecture, which boosts the speed of the processor and memory. And that means you have one powerful notebook on your hands. 50 percent faster graphics.       You'll be impressed. Instantly.       The 15-inch MacBook Pro features new discrete NVIDIA graphics that are up to 50 percent faster than before. New integrated Intel graphics also perform up to 50 percent faster. Thunderbolt and USB 3       I/O that sets new standards.       Thunderbolt technology lets you connect multiple high-performance devices to a single port - with data transfer rates up to 10 Gbps. Two new USB 3 ports are up to 10x faster than USB 2.</description><image-url>http://store.storeimages.cdn-apple.com/2782/as-images.apple.com/is/image/AppleInc/MC700</image-url><in-stock></in-stock><isbn></isbn><manufacturer-name>apple</manufacturer-name><manufacturer-sku>MD101LL/A</manufacturer-sku><name>Apple MacBook Pro 13&amp;quot; 2.5GHz (MD101LL/A) - Dual Core Intel Core i5, 2.5GHz, 4GB memory, 500GB hard drive, 13-inch</name><price>1199.0</price><retail-price>0.0</retail-price><sale-price>0.0</sale-price><sku>MD101</sku><upc>885909582969</upc></product></products></cj-api>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^

这可能是您在此处发布 XML 后格式错误的结果,如果是这样,我建议您将原始内容发布到 pastebin 或类似的无文本格式,以便我们重试。

希望有帮助。

加文

于 2012-08-21T11:36:59.163 回答