1
0
mirror of synced 2024-11-30 17:34:27 +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/*
!docs/*.conf.json !docs/*.conf.json
!docs/*.ico !docs/*.ico
.idea/*

View File

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