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

Using XML-JS with EnyoJS #1477

Open
trssssrt opened this issue Mar 21, 2018 · 3 comments
Open

Using XML-JS with EnyoJS #1477

trssssrt opened this issue Mar 21, 2018 · 3 comments

Comments

@trssssrt
Copy link

Hey,

I apologize if this is posted in the wrong place, but looking at the XML-JS's Quick Start example we have

var convert = require('xml-js');
            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 op = { compact: true, spaces: 4 };
            var result1 = convert.xml2json(xml, op);
            console.log(result1);

Converting back,


        console.log(convert. json2xml(result1, op));

Which gives the following error:

json2xml.js:4 Uncaught ReferenceError: Buffer is not defined
    at Object.module.exports [as json2xml] (json2xml.js:4)
    at enyoConstructor.handleExport (DataControl.js:357)
    at enyoConstructor.dispatch (Component.js:779)
    at enyoConstructor.dispatchEvent (Component.js:687)
    at enyoConstructor.dispatchEvent (Control.js:1311)
    at enyoConstructor.dispatchBubble (Component.js:734)
    at enyoConstructor.bubbleUp (Component.js:645)
    at enyoConstructor.dispatchEvent (Component.js:716)
    at enyoConstructor.dispatchEvent (Control.js:1311)
    at enyoConstructor.dispatchBubble (Component.js:734)
    at enyoConstructor.bubble (Component.js:617)
    at Object.dispatchBubble (dispatcher.js:161)
    at Object.dispatch (dispatcher.js:115)
    at Object.sendTap (gesture.js:142)
    at Object.up (gesture.js:102)
    at Object.mouseup (gesture.js:295)

Other than what's up there, I grabbed xml-js through

npm install --save xml-js

Thoughts?

@webOS101
Copy link
Member

Are you running this on an older version of IE by any chance? You may need to require Enyo's Buffer shim (or, apply your own).

@trssssrt
Copy link
Author

I'm using Chrome.
How do I access Enyo's Buffer?

@webOS101
Copy link
Member

Sorry, turns out I was having a bit of a brain fart. It was Blob that we had polyfilled for older browsers. I think given that it's trying to access Buffer that it is getting confused about being packed by our node build tools. Is there some way to force the library to use the browser version? Buffer is a node concept.

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