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

Error parsing xml #12

Closed
rodenp opened this issue Jun 9, 2015 · 2 comments
Closed

Error parsing xml #12

rodenp opened this issue Jun 9, 2015 · 2 comments

Comments

@rodenp
Copy link

rodenp commented Jun 9, 2015

Hi,

I am trying to use your xmltojson converter and cannot seem to get it to work.

I am trying to use this npm module as part of a nativescript application that does not have a DOM. I have noticed that the stringToXML function only caters for DOM and Microsoft ActiveXObject and returns a null value.

I am testing this code directly in node.

var xmlc= require('xmltojson');
var testString = 'It Works!'; // get some xml (string or document/node)
var myOptions = {
mergeCDATA: false,
xmlns: false
};
var result = xmlc.parseString(testString,myOptions);
console.log('xmlToJSON=' + result);
/*

and get the following errors:

var result = xmlc.parseString(testString,myOptions);
^
TypeError: Object # has no method 'parseString'
at Object. (I:\Software\nodejs\test\test.js:21:20)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

any ideas?

many thanks

Peter

@ghost
Copy link

ghost commented Jun 10, 2015

xmlToJSON is meant to be used in a browser and relies on the availability of a compatible W3C DOM API. Unfortunately, nodejs does not provide such an implementation. Others have reported success using xmlDOM https://github.com/jindw/xmldom .

@rodenp
Copy link
Author

rodenp commented Jun 11, 2015

Thanks William
I found another package xml2js which worked with very little fuss.

Thanks for your contribution to the community.
regards

Peter

@rodenp rodenp closed this as completed Jun 11, 2015
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

1 participant