1

I'm working with nodejs and I need to validate if an xml is well formed, just that.

I do not want to use xsd because the xml nodes can change.. and I do not know how to use it only to validate syntax.

XML valid

<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from> 
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

XML invalid

<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from> 
<heading>Remi

I just need to validate that the xml syntax is correct and get true if it is well formed or false if not.

Can anybody help me?

Valentina
  • 11
  • 2
  • Possible duplicate of [Validate XML Syntax / Structure with node.js](https://stackoverflow.com/questions/11050759/validate-xml-syntax-structure-with-node-js) – MatsLindh Jun 05 '19 at 08:51
  • I would try to [parse](https://stackoverflow.com/questions/14890655/the-best-node-module-for-xml-parsing) it and return false if it fails. – TGrif Jun 05 '19 at 09:08

0 Answers0