Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding strict switch from sax to DomJS
- Loading branch information
Showing
2 changed files
with
25 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var util = require('util'); | ||
var DomJS = require("dom-js").DomJS; | ||
|
||
var domjs = new DomJS(); | ||
/** | ||
* Not sure why any one would want to do this, but request comes from eddyb | ||
* Set strict to false, the XML elements all come out in UPPERCASE. | ||
* If that is a "feature" its a weird one! I think strict is mean to be about namespaces. | ||
*/ | ||
domjs.strict = false; | ||
|
||
console.log("\nExample XML"); | ||
var string = '<?xml version="1.0" encoding="UTF-8"?>' + | ||
'<xml>' + | ||
'<a>a</a>' + | ||
'<!-- the comment --><elem someAtt="fat & red">Hello "World"</elem><elem otherAtt="val1"/><elem lastAtt="val1"/></xml>'; | ||
console.log(string); | ||
domjs.parse(string, function(err, dom) { | ||
console.log(util.inspect(dom, false, 23)); | ||
console.log("serializes to : " + dom.toXml()); | ||
}); | ||
|
||
domjs.reset(); //before reuse |
This file contains 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