2016-03-28 63 views
0

我有下面这段代码从XML进一步检索产品,我可以找到任何孩子,但商家的标志URL。如果有人可以请让我知道如何访问商家徽标网址。访问孩子XML

foreach ($productsResult->Products->Product as $result) { 

echo "<a href=".$result->Offer->Url." target='_blank'><img class='productImg' src=".$result->Offer->Images[0]->Image->Url."/></a>"; 
echo "<p><b class='price'>£".$result->Offer->Price->Price."</b></p><br>"; 
echo "<p><img src=".$result->Offer->Merchant[0]->Name->Logo->Url."/></p>"; *// This is where I need help* 
echo "<p class='title'>".$result->Offer->Title.".</p><a class='goToStore w3-btn w3-blue' href=".$result->Offer->Url." target='_blank'><b>Visit Store</b></a>"; 

<Products> 
 
<Product> \t 
 
    <Offer> 
 
    <Title></Title> 
 
    <Description> </Description> 
 
    <Images> 
 
    <Image available="true"> 
 
    <Url></Url> 
 
    <Height></Height> 
 
    <Width></Width> 
 
    </Image> 
 
    <Merchant> 
 
    <Name></Name> 
 
    <Logo> 
 
    <Url>The URL I need</Url> 
 
    <Width></Width> 
 
    <Height></Height> 
 
    </Logo> 
 
    </Merchant>

感谢,

回答

0

你为什么要使用一个索引?我看起来应该只是:

$result->Offer->Merchant->Logo->Url 
+0

嗨扎克,感谢您花时间回答我的问题。我尝试了'$ result-> Offer-> Merchant-> Logo-> Url',但不幸的是它仍然没有收到商家徽标url,而我没有任何问题可以到达其他子节点。 – Seb