When using the for loop, there is an issue with parsing
- [x] Are you running the latest version?
- [x] Have you included sample input, output, error, and expected output?
- [ ] Have you checked if you are using correct configuration?
- [ ] Did you try online tool?
- [ ] Have you checked the docs for helpful APIs and examples?
Description
When using the for loop, there is an issue with parsing
Input
Code
const { XMLParser, XMLBuilder } = require('fast-xml-parser') const fs = require('fs') const _XMLParser = new XMLParser({ ignoreAttributes: false }) const _builder = new XMLBuilder({ ignoreAttributes: false, processEntities: false, format: true, }) /** *
- @param {string} filePath
- @returns jsonObj xmlObject / const xmlCodeToAST = filePath => { const fileContent = fs.readFileSync(filePath, 'utf8') return _XMLParser.parse(fileContent) } /*
- @param {Object} xmlObj
- @returns xmlString */ const astToXmlCode = xmlObj => { return _builder.build(xmlObj) }
const ast = xmlCodeToAST('./test.mpx') console.log(ast, 'ast') const xml = astToXmlCode(ast) console.log(xml, 'xml')
Output
{ script: { '': '', '#text': 'function test() {\n for (let i = 0; i' } } ast
xml
expected data
Would you like to work on this issue?
- [ ] 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.
it seems you're trying to use the same instance. Try with a new instance, everytime and check if it works.