Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.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解析总是有href_Php_Xml_Api_Parsing - Fatal编程技术网

Php解析总是有href

Php解析总是有href,php,xml,api,parsing,Php,Xml,Api,Parsing,我试图在这个api中调用我的价格,这不是问题,但问题是价格上有链接,而不是常规文本,有人能看到我做错了什么吗 <?php $x = file_get_contents("http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=authorized-key&trackingId=7000610&categoryId=7185&numItems=8&printers");

我试图在这个api中调用我的价格,这不是问题,但问题是价格上有链接,而不是常规文本,有人能看到我做错了什么吗

<?php 
$x = file_get_contents("http://sandbox.api.shopping.com/publisher/3.0/rest/GeneralSearch?apiKey=authorized-key&trackingId=7000610&categoryId=7185&numItems=8&printers");
$xml = simplexml_load_string($x);
foreach($xml->categories->category->items->product as $item)
{
print '<div style="float: left; width: 120px; padding: 10px; overflow: auto; display: block;">';
print '<a rel="nofollow" onclick="javascript:_gaq.push([\'_trackPageview\', \'/outgoing/article_exit_link/789591\']);" href="'.$item->productOffersURL.'"><img src="'.$item->images->image[0]->sourceURL.'" width="100"></a>';
print '<img src="'.$item->rating->ratingImage[0]->sourceURL.'" width="91">';
print "<br/>".l($item->name, $item->productOffersURL, array(), NULL, NULL, TRUE);
//print "<br/>".l($item->shortDescription, $item->productOffersURL, array(), NULL, NULL, TRUE);
// this is where the prices are.
print "<br/>" .l($item->minPrice, $item->productOffersURL, array(), NULL, NULL, TRUE);
print "<br/>".l($item->maxPrice, $item->productOffersURL, array(), NULL, NULL, TRUE);
print '</div>';
}
?>
categories->categories->items->productas$item)
{
打印“”;
打印“”;
打印“评级->评级图像[0]->源URL”。“width=“91”>”;
打印“
”.l($item->name,$item->productOfferURL,array(),NULL,NULL,TRUE); //打印“
”.l($item->shortDescription,$item->productOfferURL,array(),NULL,NULL,TRUE); //这就是价格所在。 打印“
”.l($item->minPrice,$item->productOfferURL,array(),NULL,NULL,TRUE); 打印“
”.l($item->maxPrice,$item->productOfferURL,array(),NULL,NULL,TRUE); 打印“”; } ?>
这是dom firebug返回的地方

<div style="float: left; width: 120px; padding: 10px; overflow: auto; display: block;">

<a href="http://www.shopping.com/Canon-Canon-EOS-400D-Twin-Lens-Kit-Silver-Body-18-55mm-EF-75-300mm-f-4-5-6-Lens/prices~linkin_id-7000610" onclick="javascript:_gaq.push(['_trackPageview', '/outgoing/article_exit_link/789591']);" rel="nofollow"><img width="100" src="http://di1.shopping.com/images/pi/cf/86/d8/58898587-100x100-0-0.jpg?p=p2.48bc03c211719c7871ea&amp;a=2&amp;c=1&amp;l=7000610&amp;t=110620123546&amp;r=1"></a>

<img width="91" src="http://img.shopping.com/sc/pr/sdc_stars_sm_4.5.gif"><br>

<a href="http://www.shopping.com/Canon-Canon-EOS-400D-Twin-Lens-Kit-Silver-Body-18-55mm-EF-75-300mm-f-4-5-6-Lens/prices~linkin_id-7000610">Canon EOS 400D / EOS Rebel XTi Digital Camera with 18-55mm and 75-300mm lenses</a><br>

<a href="http://www.shopping.com/Canon-Canon-EOS-400D-Twin-Lens-Kit-Silver-Body-18-55mm-EF-75-300mm-f-4-5-6-Lens/prices~linkin_id-7000610">598.00</a><br>

<a href="http://www.shopping.com/Canon-Canon-EOS-400D-Twin-Lens-Kit-Silver-Body-18-55mm-EF-75-300mm-f-4-5-6-Lens/prices~linkin_id-7000610">990.00</a>

</div>





您的图像标签未关闭。这可能是问题所在。请使用正确的符号

<img /> <!--instead of <img> -->

编辑:

函数l()做什么

打印“
”.l($item->maxPrice,$item->productOfferURL,array(),NULL,NULL,TRUE);
尝试使用

print "<br/>".$item->maxPrice; 
打印“
”$item->maxPrice;

相反,用firebug检查它,看看它们是否包含在
请显示HTML Dom(Chrome->右键单击->检查元素)是的,它们是完整的链接,在它里面的图像上。如果你发布DOM的一部分,对我们来说会更容易。试着写一个正确的标记。你的标记没有关闭。你可以在这里看到xml文件,它没有给出任何价格链接的指示,这是我尝试的第一件事,但它仍然给出相同的结果工作了,我以前试过,但我有错误,我想我忘记了语法什么的,谢谢
print "<br/>".$item->maxPrice;