Created
March 31, 2013 03:57
-
-
Save clintmod/5279491 to your computer and use it in GitHub Desktop.
quick nodejs test file for https://github.com/nfarina/xmldoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This test also revealed a minor bug in
xmldoc
- it expects a String in the constructor, but NodeJS is giving you aBuffer
object. So I just pushed a patch for that. Thanks!