Skip to content

Instantly share code, notes, and snippets.

@ncb000gt
Created May 10, 2012 14:10
Show Gist options
  • Select an option

  • Save ncb000gt/2653243 to your computer and use it in GitHub Desktop.

Select an option

Save ncb000gt/2653243 to your computer and use it in GitHub Desktop.

Revisions

  1. ncb000gt created this gist May 10, 2012.
    18 changes: 18 additions & 0 deletions node_format.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    var libxml = require('libxml');

    module.exports.to_string = function(assert) {
    var doc1_string = [
    '<?xml version="1.0" encoding="UTF-8"?>',
    '<root><child to="wongfoo"/></root>',
    ].join("\n");

    var expected_string = "<child/>";

    var doc1 = libxml.parseXmlString(doc1_string);
    var node = doc1.child(0).node('child');
    require('util').print(node + "\n");
    require('util').print(require('util').format.apply(console, [node]) + "\n");
    console.log(node);
    assert.equal(node.toString(), expected_string);
    assert.done();
    }