fast-xml-parser icon indicating copy to clipboard operation
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

Open lulunac27a opened this issue 1 year ago • 3 comments

  • [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.

lulunac27a avatar Oct 25 '23 04:10 lulunac27a

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.

github-actions[bot] avatar Oct 25 '23 04:10 github-actions[bot]

I can confirm the bug and reproduce.

airone01 avatar Mar 01 '24 09:03 airone01

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)

MaelAbgrall avatar Mar 02 '24 10:03 MaelAbgrall