Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use version 5 for XMLParser #682

Closed
5 of 7 tasks
Alynntheyelloweyed opened this issue Sep 19, 2024 · 2 comments
Closed
5 of 7 tasks

Unable to use version 5 for XMLParser #682

Alynntheyelloweyed opened this issue Sep 19, 2024 · 2 comments

Comments

@Alynntheyelloweyed
Copy link

  • Are you running the latest version?
  • 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

I've been testing this to replace xml2json since it doesn't seem to be maintained. I've been able to get this working for my data, however I need unpaired to parse as an empty object like my previous parser did. This was supposed to be done with v5. However, following the documentation v5 just errors out as not being found. Changing things to src/v5/... results in the same.

Input

followed the documentation for v5. Importing XMLParser from 'fast-xml-parser' works, but I don't get the output I'm looking for.

Code

import {XMLParser} from "fast-xml-parser/v5/XMLParser";
//or
import {XMLParser} from "fast-xml-parser/src/v5/XMLParser";

Output

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'F:\Local Documents\Documents\VisualStudioCodeProjects\FGU-Extension-LocalClient\node_modules\fast-xml-parser\v5\XMLParser'

Or

Could not find a declaration file for module 'fast-xml-parser/src/v5/XMLParser'. 'f:/Local Documents/Documents/VisualStudioCodeProjects/FGU-Extension-LocalClient/node_modules/fast-xml-parser/src/v5/XMLParser.js' implicitly has an 'any' type.
If the 'fast-xml-parser' package actually exposes this module, try adding a new declaration (.d.ts) file containing declare module 'fast-xml-parser/src/v5/XMLParser';

expected data

I'd expect to be able to use v5 to test the object parsing.

Would you like to work on this issue?

  • Yes
  • No
Copy link

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.

@amitguptagwl
Copy link
Member

Thanks to highlight Following is working for me. I've updated the same in the docs

const XMLParser = require("fast-xml-parser/src/v5/XMLParser");

describe("XMLParser", function() {
  it("should import v5", function() {
    const parser = new XMLParser();
  });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants