0
I am trying to implement an XML PARSE code in PHP, I believe I have set up following the right logic, but it is not working. It works if I use it with an RSS feed, but the RSS Feed doesn’t have the image links. The ultimate goal is to remove the following values:
<nome>
<descricao>
<link_produto>
<link_imagem>
<preco_promocao>
<preco_normal>
<parcelas>
<vl_parcelas>
It is returning a blank page, in the error log it returns the following:
[27-May-2017 04:18:20 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/SITE/public_html/va/artigos-complexos/afilio/afilio-vitrinexml.php on line 12
The function:
simplexml_load_file
works perfectly because
allow_url_fopen
is enabled in server php.
The code is as follows::
<link rel="stylesheet" href="/va/artigos-complexos/afilio/afilio-vitrine.css" type="text/css" />
<div class="mainproductebayfloatright-bottom">
<?php
/* XML PARSER*/
$feedurl = "http://v2.afilio.com.br/aff/aff_get_boutique.php?boutiqueid=37930-895687&token=53e355b0a09ea0.74300807&progid=1199&format=XML";
$rss = simplexml_load_file($feedurl);
foreach ($rss->boutique->produto as $item) {
$link = $item->link_do_produto;
$title = $item->nome;
$description = $item->descricao;
?>
<div class="aroundebay">
<div id="aroundebay2">
<?php
print "<div class=\"titleebay\"><a href=\"$link\">" . $title . "</a></div>";
print $description;
?>
</div>
</div>
</div>
<?php }
CSS code:
.mainproductebayfloat-bottom {
display: block;
}
#aroundebay {
margin-right: auto;
margin-left: auto;
display: table;
}
#aroundebay2 {
border: 1px #48719D;
border-style: solid;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
color: #48719D;
margin-left: 5px;
float: left;
margin-bottom: 10px;
background-color: #FFFFFF;
}
@media only screen and (min-width: 1px) {
#aroundebay2 {
height: 300px;
width: 95%;
}
}
@media only screen and (min-width: 320px) {
#aroundebay2 {
height: 220px;
width: 95%;
}
}
@media only screen and (min-width: 480px) {
#aroundebay2 {
height: 250px;
width: 95%;
}
}
@media only screen and (min-width: 640px) {
#aroundebay2 {
height: 220px;
width: 48%;
}
}
@media only screen and (min-width: 720px) {
#aroundebay2 {
height: 215px;
width: 48%;
}
}
@media only screen and (min-width: 960px) {
#aroundebay2 {
height: 250px;
width: 30%;
}
}
#aroundebay2 a {
font-weight: bolder;
}
.titleebay {
background: #48719D;
padding: 2px 5px 5px 5px;
border-radius: 5px 5px 1px 1px;
-moz-border-radius: 5px 5px 1px 1px;
-webkit-border-radius: 5px 5px 1px 1px;
}
.titleebay a {
color: #fff;
text-shadow: #000 1px 1px 1px;
height: 38px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.titleebay a:hover {
color: #CCCCCC;
}
It worked. Thank you.
– 023023