Foros del Web » Programando para Internet » Javascript »

error de codificación con xml, javascript y asp

Estas en el tema de error de codificación con xml, javascript y asp en el foro de Javascript en Foros del Web. Hola. Tengo un problema con un código denominado grabnews de edazzle.net. El código está en realidad en javascript aunque en páginas ASP. Permite grabar el ...
  #1 (permalink)  
Antiguo 23/02/2005, 05:54
Avatar de mrgubu  
Fecha de Ingreso: febrero-2002
Ubicación: Granada
Mensajes: 431
Antigüedad: 22 años, 2 meses
Puntos: 2
error de codificación con xml, javascript y asp

Hola. Tengo un problema con un código denominado grabnews de edazzle.net.

El código está en realidad en javascript aunque en páginas ASP. Permite grabar el código de un archivo XML en una base de datos Access para luego recuperarlo en HTMl con una hoja de estilo XSL.

El problema que tengo es que muchos de los archivos XML se almacenan en la BD con caracteres raros (me quita las letras con acento y se come varios carascteres a la derecha, por ejemplo, cárcel lo deja en c?el)

Eso provoca que luego el archivo XML almacenado dé errores al mostrarlo en HTML. Normalmente el error que me da es

'An invalid character was found in text content.'

El código de la página que añade los registros a la BD es la siguiente:

Código:
<%@ language="javascript" %>

<!--  

Paul Millar - GrabNews
*    Copyright (C) 2001 - 2004  Paul Millar
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version.
*
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with this program; if not, write to the Free Software
*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
*   [email protected]
-->
<%
if (Request.QueryString != "") {
addSites = Request.QueryString("sites")
addUrl = Request.QueryString("url")

// Access Connection Settings DSN
//ConString = "PROVIDER=MSDASQL;USER UID=admin;DATA SOURCE=newsfeedsmdb;"
//database = "Access"

// Access Connection Settings Local File
ConString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="+Server.MapPath("../../db/search_enjine.mdb")+";"  
database = "Access"

// MSSQL Connection Settings
// ConString = "driver={SQL Server};server=myserver.com;uid=cm;pwd=password;database=newsfeeds;"
// database = "MSSQL"

// MySQL Connection Settings
// ConString = "Driver={MySQL};DSN=cm;DATABASE=newsfeeds;"
// database = "MySQL"

var sqlConn = Server.CreateObject("ADODB.Connection")
sqlConn.Open(ConString)

var result = sqlConn.Execute("SELECT url FROM sites_rss WHERE url='"+addUrl+"';")
var result2 = sqlConn.Execute("SELECT site FROM sites_rss WHERE site='"+addSites+"';")
var time = new Date()

if (!result.eof || !result2.eof) {
Response.Write("Record Already Exists")
} else {
var xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

try {
xmlHttp.open("GET",addUrl,"False")
xmlHttp.send()
} catch (e) {
if (e) {
Response.Write(addUrl+" not a valid URL")
} 
}

if (!e) {
if (xmlHttp.statusText == "Not found") {
Response.Write(addUrl+" not found")
} else {
var xmlText = xmlHttp.responseText
var quote = /'/g
xmlText = String(xmlText).replace(quote,"''")

if (database == "Access" || database == "MSSQL") {
sqlConn.Execute("INSERT INTO sites_rss (site,url,[time],xml) VALUES ('"+addSites+"','"+addUrl+"',"+time.getHours()+",'"+xmlText+"');")
} else {
sqlConn.Execute("INSERT INTO sites_rss (site,url,time,xml) VALUES ('"+addSites+"','"+addUrl+"','"+time.getHours()+"','"+xmlText+"');")
}
Response.Write("New Entry Added")
}
}
}
sqlConn.close()
}

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Add News</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

</head>

<body>

<form action="news_add.asp" method="get">
Site Name: <input type="text" name="sites">
<br>
Newsfeed URL: <input type="text" name="url" value="http://">
<br>
<input type="submit" name="btnSubmit" id="btnSubmit" value="SUBMIT">
<input type="reset" name="btnReset" id="btnReset" value="RESET">

</form>

</body>
</html>
  #2 (permalink)  
Antiguo 23/02/2005, 16:54
Avatar de mrgubu  
Fecha de Ingreso: febrero-2002
Ubicación: Granada
Mensajes: 431
Antigüedad: 22 años, 2 meses
Puntos: 2
Encontré la solución!

http://p2p.wrox.com/topic.asp?TOPIC_ID=7695
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:15.