Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
.innerHTML -> console.log shows formatting but DOM element doesn't
        let parser = new DOMParser();
        let OFPXML = parser.parseFromString(json, "application/xml");
        Formats = OFPXML.querySelector('Formats');
        XML1 = Formats.children[1].innerHTML;
        console.log(XML1); // This retains linebreaks
        document.getElementById('text_from_XML_node_here').innerHTML = XML1;  // This does not retain them.

Console.log shows the text with linebreaks but the DOM element removed them all.

This is a low-priority question as I am just learning and experimenting with things.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The line breaks are not shown in the rendered HTML element. When DOM elements are rendered, raw newlines like \n are ignored. If you want line breaks explicitly to show, you have the following options:

  • Change the element to a <pre>
  • Replace newlines in your XML1 variable with <br />
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda