fast-xml-parser
fast-xml-parser copied to clipboard
TypeError: Cannot read properties of undefined (reading 'tagName') when parsing closing tag without an opening tag at the start of XML document
- [x] Have you included sample input, output, error, and expected output?
- [x] Are you running the latest version?
- [x] Have you checked if you are using correct configuration?
- [x] Did you try online tool?
Description
I got an error saying TypeError: Cannot read properties of undefined (reading 'tagName') when I put closing tag at the start of XML document
Input
</a>
Code
new XMLParser().parse('</a>');
XMLValidator().validate('</a>');
Output
TypeError: Cannot read properties of undefined (reading 'tagName')
expected data
Error: closing tag found at start of XML document Would you like to work on this issue?
- [x] Yes
- [ ] No
Bookmark this repository for further updates. Visit SoloThought to know about recent features.
We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo.
I can confirm the bug and reproduce.
I came here after a bug in prod that had the trace stating the same thing.
However, using lulunac27a example, I can only reproduce it in the online editor, can't on my dev machine with package version 4.3.5 and 4.3.4.
The trace I got from logs in prod is:
TypeError: Cannot read properties of undefined (reading 'tagName')
at OrderedObjParser.parseXml (/backend/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js:281:29)
at XMLParser.parse (/backend/node_modules/fast-xml-parser/src/xmlparser/XMLParser.js:35:48)