reverted .gitignore and no for-loop in run_xpath
This commit is contained in:
parent
51b627ab29
commit
befb89ba76
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,4 +4,3 @@ build/dev
|
|||||||
docs/*
|
docs/*
|
||||||
!docs/*.conf.json
|
!docs/*.conf.json
|
||||||
!docs/*.ico
|
!docs/*.ico
|
||||||
.idea/*
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user