1
0
mirror of synced 2024-11-28 00:20:48 +01:00

reverted .gitignore and no for-loop in run_xpath

This commit is contained in:
Schwörer Mike 2016-11-30 09:56:02 +01:00
parent 51b627ab29
commit befb89ba76
2 changed files with 10 additions and 22 deletions

1
.gitignore vendored
View File

@ -4,4 +4,3 @@ build/dev
docs/*
!docs/*.conf.json
!docs/*.ico
.idea/*

View File

@ -330,29 +330,18 @@ var Extract = {
}
var serializer = new XMLSerializer();
var output = "";
for (var i = 0; i < result.length; i++) {
if (i > 0) output += delimiter;
switch (result[i].nodeType) {
case Node.ELEMENT_NODE:
output += serializer.serializeToString(result[i]);
break;
case Node.ATTRIBUTE_NODE:
output += result[i].value;
break;
case Node.TEXT_NODE:
output += result[i].wholeText;
break;
case Node.COMMENT_NODE:
output += result[i].data;
break;
default:
throw new Error("Unknown Node Type: " + result[i].nodeType);
var nodeToString = function(node) {
const { nodeType, value, wholeText, data } = node;
switch (nodeType) {
case Node.ELEMENT_NODE: return serializer.serializeToString(node);
case Node.ATTRIBUTE_NODE: return value;
case Node.COMMENT_NODE: return data;
default: throw new Error(`Unknown Node Type: ${nodeType}`);
}
}
return output;
return Object.values(result).slice(0, -1) // all values except last (length)
.map(nodeToString)
.join(delimiter);
}
};