My code gets JSON from an Ajax call, which contains XML, and goes through it reading some information.
Although the parsing of the XML runs fine in Chrome, it does not in IE, since in IE outerHTML returns undefined.
I have gone through several posts and tried several possible solutions with no success.
The JavaScript code is:
$.ajax({
url: 'getJSONwithXML.do',
type:'POST',
data:'',
dataType: 'json',
cache: false
}).done(function(data) {
var jsonResp = JSON.parse(data.data.respuesta);
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(jsonResp,"text/xml");
var texto = $(xmlDoc).find('texto').prop('outerHTML');
console.log(texto); // <--- undefined in IE
$('body').append('<div>' + texto + '</div>');
});
The xml I get under jsonResp is:
<?xml version="1.0" encoding="UTF-16"?>
<envio>
<version>1.0.0</version>
<anuncios>
<remitente>
<nodoRemitente>Nodo Remitente</nodoRemitente>
</remitente>
<anuncio>
<emisor>
<nodoEmisor>Nodo Emisor</nodoEmisor>
</emisor>
<metadatos>
<id>16249</id>
</metadatos>
<contenido>
<texto>
<p>
Notificación de prueba
</p>
<p>
Notificación de prueba
</p>
<p>
Notificación de prueba
</p>
</texto>
</contenido>
</anuncio>
</anuncios>
</envio>
Under Chrome or Fireforx, texto returns
<texto>
<p>
Notificación de prueba
</p>
<p>
Notificación de prueba
</p>
<p>
Notificación de prueba
</p>
</texto>
which is what I want (the HTML code within texto tag), but in Internet Explorer I get undefined.
I have seen the textContent property but this is not what I want because it is not the HTML code.
Any ideas?