Skip to content

Instantly share code, notes, and snippets.

@clintmod
Created March 31, 2013 03:57
Show Gist options
  • Save clintmod/5279491 to your computer and use it in GitHub Desktop.
Save clintmod/5279491 to your computer and use it in GitHub Desktop.
quick nodejs test file for https://github.com/nfarina/xmldoc
var fs = require ('fs')
,xmldoc = require('xmldoc')
var xmlFileName = __dirname + '/sample.xml';
fs.readFile(xmlFileName, {encoding:'utf8'}, fs_complete);
function fs_complete(err, data) {
if (err)
throw err;
parseXml(data, this);
}
function parseXml(data, scope) {
console.log("i see it in xmldoc after var xmldoc = require('xmldoc') =")
console.log(xmldoc)
console.log("but it's undefined? xmldoc.XMLDocument = ");
console.log(xmldoc.XMLDocument)
console.log("xmldoc.hasOwnProperty('XMLDocument') = " + xmldoc.hasOwnProperty('XMLDocument'));
var xml = new xmldoc.XMLDocument(data)
console.log(xml);
}
@nfarina
Copy link

nfarina commented Mar 31, 2013

Thanks for taking the time to put this test case together!

So I think this is a capitalization issue - It's XmlDocument not XMLDocument :)

@nfarina
Copy link

nfarina commented Mar 31, 2013

This test also revealed a minor bug in xmldoc - it expects a String in the constructor, but NodeJS is giving you a Buffer object. So I just pushed a patch for that. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment