0
I have the following XML:
<offer categoryId="3588" id="154394195459775522">
<offerName>
CAMISETA DROP DEAD PRODUCTION – MASCULINA VERDE ESCURO
</offerName>
<links>
<link url="http://links.lomadee.com/ls/d25zZjsyRHd2U1I3MzsyODY4NjE3OTswOzU3OTg7MDs1NzE0O0JSOzM7aHR0cCUzQSUyRiUyRnd3dy5jZW50YXVyby5jb20uYnIlMkZwcm9tb2NhbyUzRm5leHRVcmwlM0R0LXNoaXJ0LWRyb3AtZGVhZC1wcm9kdWN0aW9uLTcwMjE0MDE4LTgxODE2OC5odG1sJTI2dHlwZSUzRHBkcCUyNmlkJTNEODE4MTY4JTI2dXRtX3NvdXJjZSUzRExvbWFkZWUlMjZ1dG1fbWVkaXVtJTNEeG1sJTI2dXRtX2NhbXBhaWduJTNETG9tYWRlZS1Ta2F0ZS1DYW1pc2V0YS0tODE4MTY4LTg2JTI2b3JpZ2VtJTNETG9tYWRlZTswOzA-.html" type="offer"/>
</links>
<thumbnail url="http://images.centauro.com.br/250x250/81816886.jpg"/>
<price>
<currency abbreviation="BRL"/>
<value>49.9</value>
<parcel>
<value>24.95</value>
<number>2</number>
<interest>0.0</interest>
</parcel>
</price>
<seller id="84" isTrustedStore="false" pagamentoDigital="false" advertiserId="5714" oneClickBuy="false" oneClickBuyValue="0" cpcDifferentiated="false">
<sellerName>Centauro</sellerName>
<thumbnail url="https://wwws.lomadee.com/programas/BR/5714/logo_185x140.png"/>
<links>
<link url="http://www.centauro.com.br" type="seller"/>
</links>
</seller>
<startOffer>1969-12-31T21:00:00-03:00</startOffer>
<endOffer>8994-08-17T04:12:55.807-03:00</endOffer>
<category id="3588" isFinal="true">
<thumbnail url="http://imagem.buscape.com.br/bp5/categorias/3588.jpg"/>
<name>Shorts Esportivo</name>
</category>
</offer>
I called xml, via php as follows:
<?php
$xml = simplexml_load_file('arquivo.xml');
foreach ($xml as $details){
echo "<href='" . $details->links ."'>" . $details->offerName . "</a><br >";
echo $details->thumbnail . '<br >';
echo "R$" . $details->price->value . '<br >';
echo $details->price->parcel->value->number . '<br >';
echo $details->seller->sellerName . '<br >';
echo '<br >';
}
?>
The problem is that it is showing only the title, without the link. It shows the value, without the splitting. It does not show the thumbnail.
Adding ----->
According to the code above, it brings a blank result always in the first line.
tried so, and no data appeared on the screen.
– GustavoCave
Wrong, he is iterating
offer. Para acessar dessa forma seria algo como
$Details->Offer->blablablabla`– gmsantos
It is not, it is iterating the Offer children nodes check in the PHP manual link the examples.
– casscarraro
I think it’s around @casscarraro , problem is that not all data is appearing, I’ve tested in several ways and nothing.
– GustavoCave
Actually, it’s iterating the kids. I ran the code here. My fault.
– gmsantos
Well, @Gustavocave to get the elements you can use as in the example I quoted above, use the $Details->"node name". If you want to search all the data you can use the foreach, however you should take care of the elements that have children, as in the case of "links", you will have to use another foreach to browse or search for a fixed element as I gave the example of "$Details->links[0]".
– casscarraro
@casscarraro created 1 variable $a = links[0]->link["url"] and called the variable in echo inside href. I haven’t had any success yet.
– GustavoCave
You should assign the value of $Details->links[0]->link["url"], ie $a = $Details->links[0]->link["url"].
– casscarraro
Infeslimente without success, I will try other ways, any other help is welcome, thanks for everything so far. casscarraro and gmsantos!
– GustavoCave
Inside the xml in the <link> tag has a call type type=Offer, this is not influencing will?
– GustavoCave
I made an echo $Details->links[0]->link["url"] . <br>; and showed the link, but when I put it inside href, it doesn’t work
– GustavoCave
It worked, but without using variable. It looked like this: echo "<a href='" . $Details->links[0]->link["url"] ." '>" . $Details->offerName . " </a><br >";
– GustavoCave