Update xml.js

This commit is contained in:
Namhyeon Go 2023-01-05 04:36:12 +09:00 committed by GitHub
parent a1c45e9bd5
commit 0ab224b987
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;