Ir ao conteúdo

Posts recomendados

Postado

   Olá, estou tentando usar o xml da saraiva (como exemplo) para fazer uma atualização automatica de preços dos produtos, mas sou muito leigo em java e gostaria de saber se alguém poderia ajudar.

 

   Exemplo de XML: http://bws.buscape.com/service/offers/lomadee/65717751673178504d42633d/BR/?sourceId=35212745&keyword=celular+apple&page=1

 

   Gostaria de usar apenas os preços dos produtos.

 

 

   Pra quem não quer abrir o link ta aqui uma parte do XML

 

<offer categoryId="77" id="211052800" productId="615365">
<offerName>
iPhone 6s Apple com 64GB e Tela 4,7 HD com 3D Touch, iOS 9, Sensor Touch ID, Câmera iSight 12MP, Wi - Fi, 4G, GPS, Bluetooth e NFC - Ouro Rosa
</offerName>
<sku>6346237</sku>
<offerShortName>Iphone 6s Apple</offerShortName>
<links>
<linkurl="http://links.lomadee.com/ls/of/Y249U1d4cDttZHNyYz0zNTIxMjc0NTtlbXBfaWQ9Nzc7bWRhcHA9NTc5ODtwcm9kX2lkPTIxMTA1MjgwMDt4bGs9aHR0cDovL3Byb2R1dG8uZXh0cmEuY29tLmJyLzYzNDYyMzc_dXRtX3NvdXJjZT1idXNjYXBlJnV0bV9tZWRpdW09Y29tcGFyYWRvcnByZWNvJnV0bV9jYW1wYWlnbj1UZWxlZm9uZXMtLS1DZWx1bGFyZXNfaU9TLS0taVBob25lJnV0bV9jb250ZW50PTYzNDYyMzcmY21fbW1jPWJ1c2NhcGVfWE1MLV8tVEVMRS1fLUNvbXBhcmFkb3ItXy02MzQ2MjM3Jjtjb3VudHJ5PUJSO2h0PWE0NWI1MDgyM2Y2MDNkMjk3NzVlMzMxZTY5MmYyMGZkO21kZHRuPTA-.html"type="offer"/>
</links>
<thumbnail url="http://thumbs.buscape.com.br/T100x100/__2.77-c946900.jpg"/>
<price>
<currency abbreviation="BRL"/>
<value>3783.03</value>
</price>
<seller id="77" isTrustedStore="false" pagamentoDigital="false" advertiserId="0" oneClickBuy="false" oneClickBuyValue="0" cpcDifferentiated="false">
<sellerName>Extra.com.br</sellerName>
<thumbnail url="http://imagem.buscape.com.br/vitrine/logo77.gif"/>
<links>
<link url="http://www.extra.com.br/?utm_source=buscape&utm_medium=comparadorpreco&utm_campaign=BuscaExtra" type="seller"/>
</links>
<contacts>
<contact value="4003-3383" label="SAC"/>
<contact value="4003-0363" label="Televendas"/>
</contacts>
<rating>
<userAverageRating>
<numComments>262722</numComments>
<rating>8.0</rating>
</userAverageRating>
<eBitRating>
<numComments>262722</numComments>
<rating>Diamante</rating>
<ratingNew>e-bit Excelente</ratingNew>
<ratingId>40</ratingId>
<ebitId>2043</ebitId>
</eBitRating>
</rating>
</seller>
</offer>

 

Basicamente só preciso de um código que chame o xml.

 

Vide que só quero usar a parte destacada em vermelho. 

 

  Desde já agradeço.

Postado

galera, n precisa mais, vi um video de um americano e consegui fzr.

 

https://www.youtube.com/watch?v=WhKRbo8MANA

 

Meu codigo ficou assim:

 

<body onload="displayprice()">

<div id='showprice'></div><br>


  <script>
   if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
   } else {// code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }
   xmlhttp.open("GET", "http://bws.buscape.com/service/offers/lomadee/65717751673178504d42633d/BR/?sourceId=35212745&keyword=world-warcraft-mares-de-guerra&page=1", false);
   xmlhttp.send();
   xmlDoc = xmlhttp.responseXML;
   document.write("<table border='1'>");
   var x = xmlDoc.getElementsByTagName("price");
   for ( i = 0; i < x.length; i++) {
    document.write("<tr><td>");
    document.write(x.getElementsByTagName("value")[0].childNodes[0].nodeValue);
    document.write("</td><td>");
   }
   document.write("</table>");
  </script>
 
<script>
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","http://bws.buscape.com/service/offers/lomadee/65717751673178504d42633d/BR/?sourceId=35212745&keyword=world-warcraft-mares-de-guerra&page=1",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 
x=xmlDoc.getElementsByTagName("price");
i=0;
function displayprice()
{
artist=(x.getElementsByTagName("value")[0].childNodes[0].nodeValue);
txt="Artist: " + artist + "<br>value:;
document.getElementById("showprice").innerHTML=txt;
}
function next()
{
if (i<x.length-1)
  {
  i++;
  displayprice();
  }
}
function previous()
{
if (i>0)
  {
  i--;
  displayprice();
  }
}
</script>
 
 </body>
 

 

 

 

 

Agora só preço estilizar :P

  • Curtir 1
  • 4 semanas depois...
Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

LANÇAMENTO!

eletronica2025-popup.jpg


CLIQUE AQUI E BAIXE AGORA MESMO!