mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 04:26:01 +00:00
improved xml importer
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
"prepublishOnly": "yarn build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"node-xml-stream": "^1.0.2",
|
||||
"node-xml-stream-parser": "^1.0.12",
|
||||
"dbgate-plugin-tools": "^1.0.7",
|
||||
"webpack": "^4.42.0",
|
||||
"webpack-cli": "^3.3.11"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const fs = require('fs');
|
||||
const stream = require('stream');
|
||||
const NodeXmlStream = require('node-xml-stream');
|
||||
const NodeXmlStream = require('node-xml-stream-parser');
|
||||
|
||||
class ParseStream extends stream.Transform {
|
||||
constructor({ itemElementName }) {
|
||||
@@ -26,6 +26,17 @@ class ParseStream extends stream.Transform {
|
||||
if (this.stack.length >= 2) {
|
||||
this.stack[this.stack.length - 2].nodes[this.stack[this.stack.length - 1].name] = text;
|
||||
}
|
||||
if (this.stack.length >= 1) {
|
||||
this.stack[this.stack.length - 1].nodes.$text = text;
|
||||
}
|
||||
});
|
||||
this.parser.on('cdata', (text) => {
|
||||
if (this.stack.length >= 2) {
|
||||
this.stack[this.stack.length - 2].nodes[this.stack[this.stack.length - 1].name] = text;
|
||||
}
|
||||
if (this.stack.length >= 1) {
|
||||
this.stack[this.stack.length - 1].nodes.$text = text;
|
||||
}
|
||||
});
|
||||
this.parser.on('closetag', (name, attrs) => {
|
||||
if (name == element) {
|
||||
|
||||
Reference in New Issue
Block a user