Foros del Web » Programación para mayores de 30 ;) » Java »

Como hago esto en JAVA

Estas en el tema de Como hago esto en JAVA en el foro de Java en Foros del Web. XML Data (currency.xml) Xml Copy Code <?xml version="1.0" encoding="utf-8"?> <currency> <name>Euro</name> <symbol>€</symbol> <exchange> <base>US$</base> <rate>1.106</rate> </exchange> </currency> ASP Page (incapable.asp) Xml Copy Code <%@language = ...
  #1 (permalink)  
Antiguo 13/07/2005, 13:10
 
Fecha de Ingreso: mayo-2005
Mensajes: 4
Antigüedad: 19 años
Puntos: 0
Pregunta Como hago esto en JAVA

XML Data (currency.xml)
Xml Copy Code
<?xml version="1.0" encoding="utf-8"?>
<currency>
<name>Euro</name>
<symbol>€</symbol>
<exchange>
<base>US$</base>
<rate>1.106</rate>
</exchange>
</currency>



ASP Page (incapable.asp)
Xml Copy Code
<%@language = "javascript"%>
<%
var doc = new ActiveXObject("Msxml2.DOMDocument.3.0");
doc.async = false;
if (doc.load(Server.MapPath("currency.xml"))==true) {
Response.ContentType = "text/xml";
Response.Write(doc.xml);
}
%>



When incapable.asp is opened from a Web browser, an error such as the following results:

Xml Copy Code
An invalid character was found in text content. Error processing resource 'http://MyWebServer/MyVirtualDirectory/incapable.asp'. Line 4, Position 10



This error is caused by the use of the Response.Write(doc.xml) instruction in the incapable.asp code. Because it calls upon ASP to encode/decode the Euro currency symbol character found in currency.xml, it fails.

However, you can fix this error. To do so, replace this Response.Write(doc.xml) instruction in incapable.asp with the following line:

Xml Copy Code
doc.save(Response);



With this line, the error does not occur. The ASP code does produce the correct output in a Web browser, as follows:

Xml Copy Code
<?xml version="1.0" encoding="utf-8" ?>
<currency>
<name>Euro</name>
<symbol>€</symbol>
<exchange>
<base>US$</base>
<rate>1.106</rate>
</exchange>
</currency>


El problema en ASP se soluciona de esta manera doc.save(Response);
Necesito imprimir un xml con caracteres raros en JAVA
Se supone que esta pagina la leo desde otra con XML.load(pagina.jsp)
y me arroja el error de caracteres no valido en el XML
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 17:15.