Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Galera, não manjo nada de ASP, porém estou precisando realizar uma pesquisa dentro de um XML, e este tem que ser feito em ASP.
Assim como pesquisa no Mysql... o Usuário manda as palavras, e se faz uma pesquisa dentro do banco.
Como posso fazer isso só que pesquisando o XML?
olha este exemplo, você pode alterá-lo para sua necessidade também
<%
'INTEGRACAO API XML - HARDVISION.COM.BR
Dim strPesq, objXML, rootNode, childNode, match
TextoSaidaHtml = TextoSaidaHtml & ".10px {font-family:Tahoma; font-size: 10px }" TextoSaidaHtml = TextoSaidaHtml & ".11px {font-family:Tahoma; font-size: 11px }" TextoSaidaHtml = TextoSaidaHtml & ".frmjob {font-family:Tahoma; font-size: 10px; color:#9c9c9c }" TextoSaidaHtml = TextoSaidaHtml & "input.FundoCinzaPop {border: 1px solid #9c9c9c;font-family: Tahoma;font-size: 10px;color: #000000;margin : 0px;}" TextoSaidaHtml = TextoSaidaHtml & "select.FundoCinzaPop {border: 1px solid #9c9c9c;font-family: Tahoma;font-size: 10px;color: #000000;margin : 0px;}" TextoSaidaHtml = TextoSaidaHtml & ".caixa {font-family:Tahoma; font-size: 11px; border: 1px #9c9c9c solid;;}" TextoSaidaHtml = TextoSaidaHtml & ".topo:link { color:#ffffff; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".topo:visited { color:#ffffff; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".topo:hover { color:#9c9c9c; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".menu:link { color:#02594d; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".menu:visited { color:#02594d; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".menu:hover { color:#ff9900; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".menu2:link { color:#000000; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".menu2:visited { color:#000000; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".menu2:hover { color:#000000; text-decoration:underline;}" TextoSaidaHtml = TextoSaidaHtml & ".menu3:link { color:#ff9900; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".menu3:visited { color:#ff9900; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".menu3:hover { color:#ff9900; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".produtos:link { color:#000000; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".produtos:visited { color:#000000; text-decoration:none;}" TextoSaidaHtml = TextoSaidaHtml & ".produtos:hover { color:#02594d; text-decoration:underline;}" TextoSaidaHtml = TextoSaidaHtml & ".barra_dep:link { color:#ffffff; text-decoration:none; font-weight:bold;}" TextoSaidaHtml = TextoSaidaHtml & ".barra_dep:visited { color:#ffffff; text-decoration:none; font-weight:bold;}" TextoSaidaHtml = TextoSaidaHtml & ".barra_dep:hover { color:#ffffff; text-decoration:underline; font-weight:bold;}" TextoSaidaHtml = TextoSaidaHtml & ".estiloh1 { font-family: Tahoma, ""Gill Sans"", Arial, sans-serif; font-size: 1px; line-height: 1px COLOR: #FFFFFE; width: 120; border:2px #ffffff solid; position:absolute; top:-400; left:-400}" if request("v1") = "0" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 0,00<option value=10" if request("v1") = "10" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 10,00<option value=30" if request("v1") = "30" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 30,00<option value=50" if request("v1") = "50" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 50,00<option value=80" if request("v1") = "80" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 80,00<option value=100" if request("v1") = "100" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 100,00<option value=300" if request("v1") = "300" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 300,00<option value=500" if request("v1") = "500" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 500,00<option value=800" if request("v1") = "800" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 800,00<option value=1000" if request("v1") = "1000" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 1000,00</select> até <select name=v2 class=10px><option value=10" if request("v2") = "10" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 10,00<option value=30" if request("v2") = "30" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 30,00<option value=50" if request("v2") = "50" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 50,00<option value=80" if request("v2") = "80" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 80,00<option value=100" if request("v2") = "100" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 100,00<option value=300" if request("v2") = "300" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 300,00<option value=500" if request("v2") = "500" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 500,00<option value=800" if request("v2") = "800" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 800,00<option value=1000" if request("v2") = "1000" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if TextoSaidaHtml = TextoSaidaHtml & ">R$ 1000,00<option value=99999" if request("v2") = "99999" OR request("v2") = "" then TextoSaidaHtml = TextoSaidaHtml & " selected" end if " TextoSaidaHtml = TextoSaidaHtml & "<table cellpadding=0 cellspacing=0><tr><td width=0></td></form></tr></table>"TimerDaLoja = Timer
Session.LCID = 1046
Session.Timeout = 40
'On Error Resume Next
response.Buffer = True
response.Expires = 0
response.CacheControl = "no-cache"
response.AddHeader "Pragma", "no-cache"
'tipo=pesq
'tipo=verprod
'tipo=mostradep
if Request.form("pesq") <> "" then
Set objXML = Server.CreateObject("Microsoft.FreeThreadedXMLDOM")
Set xmlhttp = server.CreateObject("microsoft.XMLHTTP")
xmlhttp.open "post","http://xml.hardvision.com.br/xml.api.hardvision?tipo=pesq&busca="
& Request.form("pesq"),false
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.send
objXML.async = False
objXML.loadxml(BinaryToString(xmlhttp.responseBody))
Set xmlhttp = nothing
strValorDe = Request.form("v1")
strValorAte = Request.form("v2")
Set objQtd = objXML.getElementsByTagName("quantidade")
Set objLst = objXML.getElementsByTagName("item")
intNoOfHeadlines = objLst.length
TextoSaidaHtml = TextoSaidaHtml & "<table cellpadding=0 cellspacing=0 width=575 class=10px border=0 align=left>"
ict = 0
i = 0
VarCateg = ""
for i = 0 to intNoOfHeadlines-1
Set objHdl = objLst.item(i)
s=""
for x=1 to len(objHdl.childNodes(4).text)
ch=mid(objHdl.childNodes(4).text,x,1)
if ch = "," OR ch = "0" OR ch = "1" OR ch = "2" OR ch = "3" OR ch = "4" OR ch = "5" OR ch = "6" OR ch = "7" OR ch = "8" OR ch = "9" OR ch = "0" then
s=s & ch
end if
next
numero = s
'#######################################################
if clng(strValorDe) <= clng(numero) AND clng(strValorAte) => clng(numero) then
if not Cstr(VarCateg) = Cstr(objHdl.childNodes(10).text & "/" & objHdl.childNodes(12).text & "/" & objHdl.childNodes(14).text) then
ict = ict + 1
if ict <> 1 then
TextoSaidaHtml = TextoSaidaHtml & "<tr><td height=22></td></tr>"
end if
TextoSaidaHtml = TextoSaidaHtml & "<tr><td colspan=4 height=26 valign=middle class=10px> Em <strong><a href=""" & objHdl.childNodes(11).text & """ target=_parent class=produtos><u>" & ucase(objHdl.childNodes(10).text) & "</u></a> > <a href=""" & objHdl.childNodes(13).text & """ target=_parent class=produtos><u>" & ucase(objHdl.childNodes(12).text) & "</u></a> > <a href=""" & objHdl.childNodes(15).text & """ target=_parent class=produtos><u>" & ucase(objHdl.childNodes(14).text) & "</u></a></strong></td></tr><tr><td height=8></td></tr>"
else
TextoSaidaHtml = TextoSaidaHtml & "<tr><td colspan=4 height=26 valign=middle><font class=11px color=#cccccc> --------------------------------------
-------------------------------------------------------------------------------------------------
----</font></td></tr>"
end if
if objHdl.childNodes(7).text <> "à Vista" then
TextoSaidaHtml = TextoSaidaHtml & "<table><tr><Td></TD></tr></table>Ou em até " & objHdl.childNodes(7).text
end if
TextoSaidaHtml = TextoSaidaHtml & "</td></tr>"
VarCateg = objHdl.childNodes(10).text & "/" & objHdl.childNodes(12).text & "/" & objHdl.childNodes(14).text
end if
'#######################################################
Next
if ict = 0 then
response.write "<script language=""javascript"">" & VbNewLine & "alert('Nenhum produto encontrado!');" & VbNewLine & "document.location.href = ""busca.asp"";</script>"
else
TextoSaidaHtml = TextoSaidaHtml & "</table>"
response.write TextoSaidaHtml
response.write "<font class=10px>Produtos encontrados: <strong>" & objQtd.item(0).childNodes(0).text & "</strong><br>Pesquisa realizada em: <strong>" & FormatNumber((timer - TimerDaLoja),2) & "</strong> segundo(s)</font>"
end if
else
response.write TextoSaidaHtml
end if
'#########################################################
'Função p/ leitura de acentos p/ PT-BR
'#########################################################
Function BinaryToString(strBinary)
BinaryToString=""
For intCount = 1 to LenB(strBinary)
theChar=chr(AscB(MidB(strBinary,intCount,1)))
BinaryToString = BinaryToString & theChar
Next
End Function
%>