Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/09/2014, 04:22
Avatar de angel_dope
angel_dope
 
Fecha de Ingreso: noviembre-2002
Ubicación: Valencia
Mensajes: 737
Antigüedad: 21 años, 5 meses
Puntos: 8
Respuesta: Leer XML de forma remota

Pues otra cosa más solucionada. El tema está en que al crear el archivo con fso lo crea con tipo ANSI y no como UTF-8, por lo tanto hay que hacerlo con ADODB.Stream. De esta forma lo guarda con formato UTF-8 y después no da problemas a la hora de leerlo.
Dejo el código para quien lo pueda necesitar:

Código ASP:
Ver original
  1. <%
  2. Set objSrvHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
  3. objSrvHTTP.open "GET", "http://www.dominio/temas/categoria/feed/", false
  4. objSrvHTTP.send()
  5. Feed = objSrvHTTP.responseXML.xml
  6.  
  7. const adTypeBinary = 1
  8. const adSaveCreateOverwrite = 2
  9. const adModeReadWrite = 3
  10.  
  11. Set objStream = server.CreateObject("ADODB.Stream")
  12. objStream.Open
  13. objStream.CharSet = "UTF-8"
  14. objStream.WriteText(feed)
  15.  
  16. objStream.SaveToFile server.mappath("./tmp/")& "/xml_wm2.xml" , adSaveCreateOverWrite
  17. objStream.Close
  18.  
  19. set objXml = server.CreateObject("MSXML2.DOMDocument")
  20. objxml.async = false
  21.  
  22. objxml.load(server.mappath("./tmp/xml_wm2.xml"))
  23.  
  24. ' Gestion de errores
  25. if objxml.parseError.errorCode <> 0 Then
  26.         response.Write("Error de Lectura (Por favor, ponerse en contacto con el webmaster).<br />FilePos: " & objxml.parseError.filepos & "<br /> Línea: " & objxml.parseError.Line & "<br /> Causa: " & objxml.parseError.reason & "<br /> Ocurrió en: " & objxml.parseError.srcText & "<br /> Archivo: " & objxml.parseError.URL)
  27.         response.End()
  28. end if
  29.  
  30. numNoticias = objxml.selectSingleNode("/rss/channel").childNodes.length
  31. if numNoticias <= 5 then
  32.     numnoticias = 0
  33. else
  34.     for n = 9 to 13
  35.         i=0
  36.         j=0
  37.         while j=0
  38.             if objxml.selectSingleNode("/rss/channel").childNodes(n).childNodes(i).tagname = "title" then
  39.                 response.write "titulo = " & objxml.selectSingleNode("/rss/channel").childNodes(n).childNodes(i).text
  40.                 j=1
  41.             end if
  42.             i=i+1
  43.         wend
  44.         i=0
  45.         j=0
  46.         while not j<>0
  47.             if objxml.selectSingleNode("/rss/channel").childNodes(n).childNodes(i).tagname = "link" then
  48.                 response.write "<br>enlace = " & objxml.selectSingleNode("/rss/channel").childNodes(n).childNodes(i).text
  49.                 j=1
  50.             end if
  51.             i=i+1
  52.         wend
  53.         i=0
  54.         j=0
  55.         while not j<>0
  56.             if objxml.selectSingleNode("/rss/channel").childNodes(n).childNodes(i).tagname = "description" then
  57.                 response.write "<br>Resumen = " & objxml.selectSingleNode("/rss/channel").childNodes(n).childNodes(i).text
  58.                 j=1
  59.             end if
  60.             i=i+1
  61.         wend
  62.         i=0
  63.         j=0
  64.         while not j<>0
  65.             if objxml.selectSingleNode("/rss/channel").childNodes(n).childNodes(i).tagname = "content:encoded" then
  66.                 response.write "<br><br>Total = " & objxml.selectSingleNode("/rss/channel").childNodes(n).childNodes(i).text
  67.                 j=1
  68.             end if
  69.             i=i+1
  70.         wend
  71.         response.write "<br><br>"
  72.     next
  73. end if
  74. %>
__________________
Vayamos por Partes :: Jack el Destripador