Guest User

Untitled

a guest
Oct 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. $.ajax({
  2. url: 'getJSONwithXML.do',
  3. type:'POST',
  4. data:'',
  5. dataType: 'json',
  6. cache: false
  7. }).done(function(data) {
  8. var jsonResp = JSON.parse(data.data.respuesta);
  9. var parser = new DOMParser();
  10. var xmlDoc = parser.parseFromString(jsonResp,"text/xml");
  11. var texto = $(xmlDoc).find('texto').prop('outerHTML');
  12. console.log(texto);
  13. $('body').append('<div>' + texto + '</div>');
  14. });
  15.  
  16. <?xml version="1.0" encoding="UTF-16"?>
  17. <envio>
  18. <version>1.0.0</version>
  19. <anuncios>
  20. <remitente>
  21. <nodoRemitente>Nodo Remitente</nodoRemitente>
  22. </remitente>
  23. <anuncio>
  24. <emisor>
  25. <nodoEmisor>Nodo Emisor</nodoEmisor>
  26. </emisor>
  27. <metadatos>
  28. <id>16249</id>
  29. </metadatos>
  30. <contenido>
  31. <texto>
  32. <p>
  33. Notificación de prueba
  34. </p>
  35. <p>
  36. Notificación de prueba
  37. </p>
  38. <p>
  39. Notificación de prueba
  40. </p>
  41. </texto>
  42. </contenido>
  43. </anuncio>
  44. </anuncios>
  45. </envio>
  46.  
  47. <texto>
  48. <p>
  49. Notificación de prueba
  50. </p>
  51. <p>
  52. Notificación de prueba
  53. </p>
  54. <p>
  55. Notificación de prueba
  56. </p>
  57. </texto>
  58.  
  59. var node = $(xml).find('texto')[0]; // get DOM node
  60. // Try outerHTML. If not available, use XMLSerializer
  61. var texto = node.outerHTML || new XMLSerializer().serializeToString(node);
  62.  
  63. if($(this).find('texto').length){
  64. debugger;
  65. var texto = $(this).find('texto').prop('outerHTML');
  66. . . .
  67. }
  68.  
  69. var el = $(this).find('texto');
  70.  
  71. if(el.length){
  72. debugger;
  73. var texto = el.prop('outerHTML');
  74. . . .
  75. }
Add Comment
Please, Sign In to add comment