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

135
Vistas
Parsing HTML to json object

So I am looking to create a script to return certain values from a JSON. Part of this JSON object I have is HTML. How do I parse the HTML so I can use it in a JSON object?

This is the HTML:

<span style="color:#800000">protected</span></div></div>
<div><div><span style="font-weight:bold;font-size:150%">wummie</span><br /><span style="font-size:105%">Independent Faction</span><br /><span style="font-style:italic;font-size:110%">woman</span><br /><br /><span style="font-weight:bold">SlowlyWastingAway:</span> Deusphage<br /><br /><span style="font-weight:bold">Member Count:</span> 1<br /><span style="font-weight:bold">Age:</span> 2 years, 5 months and 6 days<br /><span style="font-weight:bold">Bank:</span> 0 Regals<br /><br /><span style="font-weight:bold">Flags:</span><br /><span style="color:#800000">open</span> | <span style="color:#800000">monsters</span> | <span style="color:#008000">animals</span><br />

How would I parse it so it is like: wummie Independent Faction woman

SlowlyWastingAway: Deusphage

Member Count: 1 Age: 2 years, 5 months and 6 days Bank: 0 Regals

Flags: open | monsters | animals

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

0

Maybe not a standard answer but it works.

var a=document.createElement("div")
a.innerHTML=`<span style="color:#800000">protected</span></div></div>
<div><div><span style="font-weight:bold;font-size:150%">wummie</span><br /><span style="font-size:105%">Independent Faction</span><br /><span style="font-style:italic;font-size:110%">woman</span><br /><br /><span style="font-weight:bold">SlowlyWastingAway:</span> Deusphage<br /><br /><span style="font-weight:bold">Member Count:</span> 1<br /><span style="font-weight:bold">Age:</span> 2 years, 5 months and 6 days<br /><span style="font-weight:bold">Bank:</span> 0 Regals<br /><br /><span style="font-weight:bold">Flags:</span><br /><span style="color:#800000">open</span> | <span style="color:#800000">monsters</span> | <span style="color:#008000">animals</span><br />`
.replace(/<br \/>/g,"\n")

then a.innerText is what you want

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