Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

fabiosc80

Recuperar valor de um XML e exibir em HTML

Recommended Posts

Olá,Preciso recuperar o valor de um XML que está numa página na internet e exibir o html desse XML.Porem não tenho a mínima idéia de como se faz isso.Alguem poderia me ajudar?Grato desde de já.

Compartilhar este post


Link para o post
Compartilhar em outros sites

seria isso?

<%' Script ASP Para leitura de arquivos de RSS.url = "http://oglobo.globo.com/rss/plantao.xml" 'Aqui vai o endereço do arquivo RSS, ou do arquivo "gerador"' Criando Objeto XMLSet objXML = Server.CreateObject("msxml2.DOMDocument.3.0") objXML.async = false objXML.setProperty "ServerHTTPRequest", True ' Não validar o arquivoobjXML.validateOnParse =false' true ' Retirar espaços objXML.preserveWhiteSpace = false blnLoaded = objXML.Load(url) If Not blnLoaded Then     Response.write "Nenhum notícia na fonte!" Else    set objNodeList = objXML.getElementsByTagName("channel")     For Each objNode In objNodeList         For Each objNode2 In objNode.childNodes         Select Case objNode2.nodeName         Case "title"             html = html &"<tr><td><b>"            html = html &objNode2.firstChild.nodevalue             html = html &"</b></td></tr>"        Case "link"             html = html &"<tr><td><a target=_blank href="& objNode2.firstChild.nodevalue &">"            html = html & objNode2.firstChild.nodevalue             html = html &"</a></td></tr>"        Case "description" 'Está desabilitado para exibir apenas os links            html = html &"<tr><td><i>"            html = html & objNode2.firstChild.nodevalue             html = html &"</i></td></tr>"        End Select         Next    Next     html = html &"<tr><td><hr></td></tr>"    Set objNodeList = objXML.getElementsByTagName("item")     For Each objNode In objNodeList         For Each objNode2 In objNode.childNodes             Select Case objNode2.nodeName             Case "title"                 strTitle = objNode2.firstChild.nodevalue             Case "link"                 strURL = objNode2.firstChild.nodevalue             Case "description"                 strDescription = objNode2.firstChild.nodevalue             End Select         Next         html = html &"<tr><td><li/><b><a target=_blank href="& strURL &">"& strTitle &"</a></b><br>"& strDescription &"</td></tr>"        strTitle = ""         strURL = ""         strDescription = ""     Next     html = "<table>"& html &"</table>"    set objNodeList = Nothing End if %><html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></head><body><font face="Verdana" style="font-size: 9pt"><%Response.write (html)%></font></body></html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.