mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-29 08:47:50 +00:00
Move the editions into a subfolder
This commit is contained in:
36
editions/tw2/source/tiddlywiki/tests/js/xml.js
Executable file
36
editions/tw2/source/tiddlywiki/tests/js/xml.js
Executable file
@@ -0,0 +1,36 @@
|
||||
tests_xml = {
|
||||
|
||||
parse: function(text) {
|
||||
var doc;
|
||||
if(window.ActiveXObject) {
|
||||
doc = new ActiveXObject("Microsoft.XMLDOM");
|
||||
doc.async = "false";
|
||||
doc.loadXML(text);
|
||||
} else {
|
||||
var parser = new DOMParser();
|
||||
doc = parser.parseFromString(text,"text/xml");
|
||||
}
|
||||
if(!doc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
doc.xpath = function(expression, type) {
|
||||
var t;
|
||||
|
||||
if(type == "string") { t = XPathResult.STRING_TYPE; }
|
||||
if(type == "number") { t = XPathResult.NUMBER_TYPE; }
|
||||
if(type == "boolean") { t = XPathResult.BOOLEAN_TYPE; }
|
||||
if(type == "singlenode") { t = XPathResult.SINGLENODE_TYPE; }
|
||||
|
||||
var res = this.evaluate(expression, this, null, t, null);
|
||||
|
||||
if(type == "string") { return res.stringValue; }
|
||||
if(type == "number") { return res.numberValue; }
|
||||
if(type == "boolean") { return res.booleanValue; }
|
||||
if(type == "singleNode") { return this.singleNodeValue; }
|
||||
return null;
|
||||
};
|
||||
|
||||
return doc;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user