- 
                Notifications
    
You must be signed in to change notification settings  - Fork 179
 
Open
Description
Code:
const convert = require('xml-js');
const xml1 = '<?xml version="1.0" encoding="UTF-8"?><root>This is a <x>tag</x></root>';
const xml2 = '<?xml version="1.0" encoding="UTF-8"?><root>This is a <>tag</></root>';
try {
  const result1 = convert.xml2json(xml1, {compact: true, spaces: 4});
  console.log("Document 1 parsed successfully:", result1);
} catch (e) {
  console.error("Error parsing document 1:", e.message);
}
try {
  const result2 = convert.xml2json(xml2, {compact: true, spaces: 4});
  console.log("Document 2 parsed successfully:", result2);
} catch (e) {
  console.error("Error parsing document 2:", e.message);
}
The second one correctly throws an error, but the error message says "Unmatched closing tag: <x>" even though there is no <x> tag in the document. I think there is some left-over state from parsing the first document, which hints at possibly larger problems. If you only parse the second document without parsing the first one first, then the error is "Unmatched closing tag: <>" which is correct
Metadata
Metadata
Assignees
Labels
No labels