Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.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);
- $('body').append('<div>' + texto + '</div>');
- });
- <?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>
- <texto>
- <p>
- Notificación de prueba
- </p>
- <p>
- Notificación de prueba
- </p>
- <p>
- Notificación de prueba
- </p>
- </texto>
- var node = $(xml).find('texto')[0]; // get DOM node
- // Try outerHTML. If not available, use XMLSerializer
- var texto = node.outerHTML || new XMLSerializer().serializeToString(node);
- if($(this).find('texto').length){
- debugger;
- var texto = $(this).find('texto').prop('outerHTML');
- . . .
- }
- var el = $(this).find('texto');
- if(el.length){
- debugger;
- var texto = el.prop('outerHTML');
- . . .
- }
Add Comment
Please, Sign In to add comment