mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
Update xml.js
This commit is contained in:
parent
a1c45e9bd5
commit
0ab224b987
20
lib/xml.js
20
lib/xml.js
|
@ -119,15 +119,16 @@ var XMLObject = function(dom) {
|
|||
this.encode = function(value, type) {
|
||||
try {
|
||||
var dom = this.getDOM();
|
||||
var node = dom.createElement("XMLNode");
|
||||
|
||||
dom.dataType = type;
|
||||
node.dataType = type;
|
||||
if (type.indexOf("bin.") == 0) {
|
||||
dom.nodeTypedValue = (new StreamConvert(value)).toBinary();
|
||||
node.nodeTypedValue = (new StreamConvert(value)).toBinary();
|
||||
} else {
|
||||
dom.nodeTypedValue = value;
|
||||
node.nodeTypedValue = value;
|
||||
}
|
||||
|
||||
return dom.text;
|
||||
return node.text;
|
||||
} catch (e) {
|
||||
console.error("XMLObject->encode():", e.message);
|
||||
}
|
||||
|
@ -136,15 +137,16 @@ var XMLObject = function(dom) {
|
|||
this.decode = function(value, type) {
|
||||
try {
|
||||
var dom = this.getDOM();
|
||||
var node = dom.createElement("XMLNode");
|
||||
|
||||
dom.dataType = type;
|
||||
node.dataType = type;
|
||||
if (type.indexOf("bin.") == 0) {
|
||||
dom.text = (new StreamConvert(value)).toString();
|
||||
node.text = (new StreamConvert(value)).toString();
|
||||
} else {
|
||||
dom.text = value;
|
||||
node.text = value;
|
||||
}
|
||||
|
||||
return dom.nodeTypedValue;
|
||||
return node.nodeTypedValue;
|
||||
} catch (e) {
|
||||
console.error("XMLObject->decode():", e.message);
|
||||
}
|
||||
|
@ -159,6 +161,6 @@ exports.load = function(s) {
|
|||
return (new XMLObject()).load(s);
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "XML interface (xml.js) version 0.1";
|
||||
exports.VERSIONINFO = "XML interface (xml.js) version 0.2";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user