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

222
Vistas
Parsing XML elements without closing tags in JavaScript

I am running into a problem with the fast-xml-parser npm package. I'm trying to parse some XML from an external source that has a series of elements with self closing tags but those elements have data in them that I need. Consider the following snippet:

const options = {
    unpairedTags: ["link"]
};
const parser = new XMLParser(options);
const obj = parser.parse('<link something="idc" data="i care about this data"/>');

You can see that I have tried adding an unpaired tag but obviously this doesn't work because the idc and data properties are not considered XML so obj still lands up being blank

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

0

The default is to ignore attributes. Set the parse option ignoreAttributes

const options = {
  unpairedTags: ["link"],
  ignoreAttributes : false
};

https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md

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