Does anyone know why this does not work?

this is part of an npm (xml-js) to convert xml to json but it does not return any results, why?

import xmljs from 'xml-js';

var convert = xmljs
var xml =
 '<?xml version="1.0" encoding="utf-8"?>' +
 '<note importance="high" logged="true">' +
 '    <title>Happy</title>' +
 '    <todo>Work</todo>' +
 '    <todo>Play</todo>' +
 '</note>';
var result1 = convert.xml2json(xml, {compact: true, spaces: 4});
var result2 = convert.xml2json(xml, {compact: false, spaces: 4});
console.log(result1, '\n', result2);

Are you using it correctly:

var convert = require('xml-js');

Velo: Working with npm Packages | Help Center | Wix.com
GitHub - nashwaan/xml-js: Converter utility between XML text and Javascript object / JSON text.

“require is not defined”, i used:

import xmljs from 'xml-js'; 

my guide: GitHub - nashwaan/xml-js: Converter utility between XML text and Javascript object / JSON text.
but not work :frowning:

@jessyerena

Are you sure that this is not just a quick example of how to set it up and you do not need to edit it to suit your own needs?

Finally, remember that to use it, you need to import it through the backend:
https://support.wix.com/en/article/corvid-managing-external-code-libraries-with-the-package-manager#using-an-installed-package241

Hope you can get it sorted out soon, or if it still doesn’t want to work, that somebody else can offer a better and correct fix to your issue.

Here’s an example that uses the xml-js NPM library available in the Wix Package Manager to modify an existing SVG image.
View the “Live” site in a browser page
Open the site template in the Wix Editor