aggregation-platform/app/xmloperation.js

608 lines
20 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var fs = require('fs');
var dom = require("xmldom").DOMParser;
var select = require('xpath.js');
//var dataDetailPath = "/home/server_data/data-detail.xml"
//var dataPath = "/home/server_data/data.xml"
//var versionPath = "/home/server_data/version.txt"
var allDataPath = process.env.ALL_DATA || '/home/all_data';
var dataDetailPath = allDataPath + "/collecting_data/data-detail.xml"
var dataPath = allDataPath + "/collecting_data/data.xml"
var versionPath = allDataPath+ "/collecting_data/version.txt"
//<2F><><EFBFBD><EFBFBD>fileId<49><64><EFBFBD><EFBFBD>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ŵ<EFBFBD>λ<EFBFBD><CEBB>
function getVersionPath(fileId){
fileId = fileId.replace(/\"/g, "");
var item = "<item";
// fs<66><73>ȡ<EFBFBD><C8A1> xmldomת<6D><D7AA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
var filedata = fs.readFileSync(dataDetailPath, "utf-8");
var itemArray = filedata.split(item);
var itemsize = itemArray.length;
var version = {value:0};
// ͬһ<CDAC><D2BB>id,<2C><>Ӧ<EFBFBD><D3A6>item<65>ж<EFBFBD><D0B6>ٸ<EFBFBD><D9B8><EFBFBD>
for(var i = 1; i < itemsize; i++){
if(itemArray[i].indexOf(fileId)!= -1){
var oldBigVersion = itemArray[i].split("<version>")[1].split("</version>")[0];
if(version.value < oldBigVersion){
version.value = oldBigVersion;
}
}
}
version.value ++;
return version.value;
}
function mkdataForPage(collecttime, realtype, realpath, realbatch, realid, realname, version){
// var resultXmlData = "";
// var realpath = "/uplaods/";
// var realtype = "01";
// var realbatch = "01_A";
// var realid = "32550_111";
// var realname = "<22>Ͼ<EFBFBD><CFBE><EFBFBD>_<EFBFBD><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<EFBFBD><5F>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>ϵͳ";
//json<6F><6E><EFBFBD>Եĸ<D4B5>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>@
var type ="id=\""+realtype+"\"";
var batch = "id=\""+realtype+"_"+realbatch+"\"";
var id = realtype+"_"+realbatch+"_"+realid+"\"";
var versionid = realtype+"_"+realbatch + "_"+realid + "_" + version +"\"";
var name = "name=\""+realname+"\"";
var path = "path=\""+realpath+"\"";
var versionstrutf = fs.readFileSync(versionPath, "utf-8");
console.log(typeof versionstrutf);
console.log("------------- mkdataForPage --------------");
fs.readFile(dataPath, "utf-8", function(err, data){
if(err){
console.log("<22><>ȡ<EFBFBD>ļ<EFBFBD> "+dataDetailPath+" fail " + err);
}
else{
var dataNodes = data.split("<node");
var istype ="0";
var isbatch ="0";
var isexist ="0";
var sizel = dataNodes.length;
for(var i=0; i < sizel; i++){
if(dataNodes[i].indexOf(type) != -1)
{
istype ="1";
}
if((istype == "1") && (dataNodes[i].indexOf(batch) != -1))
{
isbatch ="1";
}
//id<69><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ψһ<CEA8>ģ<EFBFBD> <node id="32550_113"
if(isbatch == "1")
{//<2F><><EFBFBD><EFBFBD><EFBFBD>ӵİ汾
var nodestr = "";
if(dataNodes[i].indexOf(id) != -1){
nodestr = nodestr + "<node id=\""+ versionid + " name=\"" + realname+"\("+ versionstrutf + version + ")\"";
nodestr = nodestr + " path=\""+ realpath +"\"" + " time=\""+collecttime+ "\"></node>\n";
isexist = "1";
dataNodes[i] = dataNodes[i] + nodestr;
}
}
}
if(isexist.indexOf("1") == -1){
var nodestr = "";
for(var i=0; i < sizel; i++){
if(dataNodes[i].indexOf(batch) != -1){
var items = dataNodes[i].split("</");
if(items.length == 1){
//<2F><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ϵͳ<CFB5><CDB3>---<2D><EFBFBD><E6B1BE>Ϣ<EFBFBD><CFA2>
nodestr = nodestr + "<node id=\"" + id +" "+ name + ">\n";
nodestr = nodestr + "<node id=\""+ versionid + " name=\"" + realname +"\(" + versionstrutf + version + ")\"";
nodestr = nodestr + " path=\""+ realpath +"\"" + " time=\""+collecttime+ "\"></node>\n</node>\n";
isexist = "1";
dataNodes[i] = dataNodes[i] + nodestr;
break;
}
else{
var items = dataNodes[i].split("</node");
nodestr = nodestr + "<node id=\"" + id +" "+ name + ">\n";
nodestr = nodestr + "<node id=\""+ versionid + " name=\"" + realname+"\(" + versionstrutf + version + ")\"";
nodestr = nodestr + " path=\""+ realpath +"\"" + " time=\""+collecttime+ "\"></node>\n</node>\n";
isexist = "1";
nodestr = items[0] +"\n" + nodestr +"\n</node>\n";
dataNodes[i] = nodestr;
break;
}
}
}
}
var resultdatastr = "";
for(var j=0; j < sizel-1; j++){
resultdatastr = resultdatastr + dataNodes[j] + "<node";
}
resultdatastr = resultdatastr + dataNodes[sizel-1]+"";
console.log("--------22222222-----------------");
console.log(resultdatastr);
console.log(typeof resultdatastr);
fs.writeFile(dataPath, resultdatastr, function(err){
if(err)
console.log(err);
else
console.log('has finished');
});
}
});
}
//saveByIdToXml("01", "B", "321200_0", "̩<><CCA9><EFBFBD><EFBFBD>_<EFBFBD><5F>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>ϵͳ2","<22><><EFBFBD><EFBFBD>" , "̩<><CCA9>2", "<22>б<EFBFBD><D0B1><EFBFBD>", "<22><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>ϵͳ", "321200_0", "0000", "lim", "13323225656",5);
function saveByIdToXml(collecttime, type, dataTimes, id, name, province, city, county, system, areacode, systemcode, contacts, phone, version, realpath){
var dataTimetemstr = "batch=\""+ type +"_" + dataTimes + "\"";
typestr = "type=\""+type+"\"";
var datatype = "<datatype";
var dataTimestr = "<dataTimes";
var dataTimeEndstr = "</dataTimes>";
var item = "<item";
var itemEnd = "</item>";
var dataEnd = "</data>";
id = type +"_" + dataTimes + "_" + id;
// <20><>ȡ
// var data = fs.readFileSync(dataDetailPath, "utf-8");
// <20><>ȡ
fs.readFile(dataDetailPath, "utf-8", function(err, data){
//fs.readFile("data.txt", function(err, data){
if(err){
console.log("<22><>ȡ<EFBFBD>ļ<EFBFBD> "+dataDetailPath+" fail " + err);
}
else{
console.log(data);
var resultStr = "";
// gbk <20><><EFBFBD><EFBFBD> linux<75><78><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//var str = iconv.decode(data,'gbk');
//data = str;
var typeArray = data.split(datatype);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E7B1A3>{typeArray[0]:ͷ<><CDB7> typeArray[1]:<3A><EFBFBD><E7B1A3> typeArray[2]:<3A><><EFBFBD><EFBFBD>}
if(typeArray[1].indexOf(typestr)== -1){
resultStr += typeArray[0];
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E7B1A3>
resultStr += datatype;
resultStr += typeArray[1];
//<2F><><EFBFBD><EFBFBD> <20><>typeArray[2]
var timesArray = typeArray[2].split(dataTimestr);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>εģ<CEB5><C4A3>ǵ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>; {timesArray[0]:ͷ<><CDB7> timesArray[1]:1<><31><EFBFBD>Σ<EFBFBD> timesArray[2]:2<><32><EFBFBD><EFBFBD>}
if(timesArray[1].indexOf(dataTimetemstr)== -1){
resultStr += datatype;
resultStr += timesArray[0];
// <20><><EFBFBD>ϵ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>
resultStr += dataTimestr;
resultStr += timesArray[1];
var itemArray = timesArray[2].split(item);
var itemsize = itemArray.length;
var nowDate = new Date();
// itemԪ<6D><D4AA>
var itemStr = "<item id=\""+id+"_"+version+"\">\n";
itemStr += "\t\t\t\t<name>"+name+"</name>\n";
itemStr += "\t\t\t\t<collecttime>"+collecttime+"</collecttime>\n";
itemStr += "\t\t\t\t<time>"+nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+"</time>\n";
itemStr += "\t\t\t\t<province>"+province+"</province>\n";
itemStr += "\t\t\t\t<city>"+city+"</city>\n";
itemStr += "\t\t\t\t<county>"+county+"</county>\n";
itemStr += "\t\t\t\t<system>"+system+"</system>\n";
itemStr += "\t\t\t\t<version>"+version+"</version>\n";
itemStr += "\t\t\t\t<path>"+realpath+"</path>\n";
itemStr += "\t\t\t\t<areacode>"+areacode+"</areacode>\n";
itemStr += "\t\t\t\t<systemcode>"+systemcode+"</systemcode>\n";
itemStr += "\t\t\t\t<contacts>"+contacts+"</contacts>\n";
itemStr += "\t\t\t\t<phone>"+phone+"</phone>\n";
itemStr += "\t\t\t\t<type>"+type+"</type>\n\t\t\t"+itemEnd+"\n\t\t";
// <20><><EFBFBD> <20><> resultStr
// û<><C3BB> item<65><6D> itemsize ==1
if(itemsize ==1){
var dataTimebeginstr = itemArray[0].split(dataTimeEndstr);
resultStr += dataTimestr;
resultStr += dataTimebeginstr[0];
resultStr += "\t" + itemStr;
resultStr += dataTimeEndstr;
for(var i = 1; i < dataTimebeginstr.length;i++){
resultStr += dataTimebeginstr[i];
}
}
// <20><> item<65><6D>
else{
resultStr += dataTimestr;
resultStr += itemArray[0];
if(version == 1){
for(var i=1; i < itemsize-1; i++){
resultStr += item;
resultStr += itemArray[i];
}
resultStr += itemStr + "\t";
resultStr += item;
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
resultStr += itemArray[itemsize-1];
}
else{
var addtimes = 0;
var isadd = 0;
for(var i=1; i < itemsize-1; i++){
isadd++;
if(addtimes == 0){
if(itemArray[i].indexOf(id)!= -1){
resultStr += itemStr + "\t";
addtimes = 1;
}
}
resultStr += item;
resultStr += itemArray[i];
}
if(isadd == 0){
if(addtimes == 0){
if(itemArray[i].indexOf(id)!= -1){
resultStr += itemStr + "\t";
addtimes = 1;
}
}
}
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
resultStr += item;
resultStr += itemArray[itemsize-1];
}
}
}
// <20><>1<EFBFBD><31><EFBFBD><EFBFBD>ʱ
else{
resultStr += datatype;
resultStr += timesArray[0];
resultStr += dataTimestr;
// item Ԫ<><D4AA>
var itemArray = timesArray[1].split(item);
var itemsize = itemArray.length;
var nowDate = new Date();
// itemԪ<6D><D4AA>
var itemStr = "<item id=\""+id+"_"+version+"\">\n";
itemStr += "\t\t\t\t<name>"+name+"</name>\n";
itemStr += "\t\t\t\t<collecttime>"+collecttime+"</collecttime>\n";
itemStr += "\t\t\t\t<time>"+nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+"</time>\n";
itemStr += "\t\t\t\t<province>"+province+"</province>\n";
itemStr += "\t\t\t\t<city>"+city+"</city>\n";
itemStr += "\t\t\t\t<county>"+county+"</county>\n";
itemStr += "\t\t\t\t<system>"+system+"</system>\n";
itemStr += "\t\t\t\t<version>"+version+"</version>\n";
itemStr += "\t\t\t\t<path>"+realpath+"</path>\n";
itemStr += "\t\t\t\t<areacode>"+areacode+"</areacode>\n";
itemStr += "\t\t\t\t<systemcode>"+systemcode+"</systemcode>\n";
itemStr += "\t\t\t\t<contacts>"+contacts+"</contacts>\n";
itemStr += "\t\t\t\t<phone>"+phone+"</phone>\n";
itemStr += "\t\t\t\t<type>"+type+"</type>\n\t\t\t"+itemEnd+"\n\t\t";
// <20><><EFBFBD> <20><> resultStr
// û<><C3BB> item<65><6D> itemsize ==1
if(itemsize ==1){
var dataTimebeginstr = itemArray[0].split(dataTimeEndstr);
resultStr += dataTimebeginstr[0];
resultStr += "\t" + itemStr;
resultStr += dataTimeEndstr;
for(var i = 1; i < dataTimebeginstr.length;i++){
resultStr += dataTimebeginstr[i];
}
}
// <20><> item<65><6D>
else{
resultStr += itemArray[0];
if(version == 1){
for(var i=1; i < itemsize-1; i++){
resultStr += item;
resultStr += itemArray[i];
}
resultStr += itemStr + "\t";
resultStr += item;
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
resultStr += itemArray[itemsize-1];
}
else{
var addtimes = 0;
var isadd = 0;
for(var i=1; i < itemsize-1; i++){
isadd++;
if(addtimes == 0){
if(itemArray[i].indexOf(id)!= -1){
resultStr += itemStr + "\t";
addtimes = 1;
}
}
resultStr += item;
resultStr += itemArray[i];
}
if(isadd == 0){
if(addtimes == 0){
if(itemArray[i].indexOf(id)!= -1){
resultStr += itemStr + "\t";
addtimes = 1;
}
}
}
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
resultStr += item;
resultStr += itemArray[itemsize-1];
}
}
//Ȼ<><C8BB><EFBFBD><EFBFBD>ϵ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>
resultStr += dataTimestr;
resultStr += timesArray[2];
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
else{
resultStr += typeArray[0];
//<2F><20><>typeArray[1]
var timesArray = typeArray[1].split(dataTimestr);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><><EFBFBD>ǵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>εģ<CEB5><C4A3>ǵ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>; {timesArray[0]:ͷ<><CDB7> timesArray[1]:1<><31><EFBFBD>Σ<EFBFBD> timesArray[2]:2<><32><EFBFBD><EFBFBD>}
if(timesArray[1].indexOf(dataTimetemstr)== -1){
resultStr += datatype;
resultStr += timesArray[0];
// <20><><EFBFBD>ϵ<EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD>
resultStr += dataTimestr;
resultStr += timesArray[1];
var itemArray = timesArray[2].split(item);
var itemsize = itemArray.length;
var nowDate = new Date();
// itemԪ<6D><D4AA>
var itemStr = "<item id=\""+id+"_"+version+"\">\n";
itemStr += "\t\t\t\t<name>"+name+"</name>\n";
itemStr += "\t\t\t\t<collecttime>"+collecttime+"</collecttime>\n";
itemStr += "\t\t\t\t<time>"+nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+"</time>\n";
itemStr += "\t\t\t\t<province>"+province+"</province>\n";
itemStr += "\t\t\t\t<city>"+city+"</city>\n";
itemStr += "\t\t\t\t<county>"+county+"</county>\n";
itemStr += "\t\t\t\t<system>"+system+"</system>\n";
itemStr += "\t\t\t\t<version>"+version+"</version>\n";
itemStr += "\t\t\t\t<path>"+realpath+"</path>\n";
itemStr += "\t\t\t\t<areacode>"+areacode+"</areacode>\n";
itemStr += "\t\t\t\t<systemcode>"+systemcode+"</systemcode>\n";
itemStr += "\t\t\t\t<contacts>"+contacts+"</contacts>\n";
itemStr += "\t\t\t\t<phone>"+phone+"</phone>\n";
itemStr += "\t\t\t\t<type>"+type+"</type>\n\t\t\t"+itemEnd+"\n\t\t";
// <20><><EFBFBD> <20><> resultStr
// û<><C3BB> item<65><6D> itemsize ==1
if(itemsize ==1){
var dataTimebeginstr = itemArray[0].split(dataTimeEndstr);
resultStr += dataTimestr;
resultStr += dataTimebeginstr[0];
resultStr = resultStr + "\t" + itemStr;
resultStr += dataTimeEndstr;
for(var i = 1; i < dataTimebeginstr.length;i++){
resultStr += dataTimebeginstr[i];
}
}
// <20><> item<65><6D>
else{
resultStr += dataTimestr;
resultStr += itemArray[0];
if(version == 1){
for(var i=1; i < itemsize-1; i++){
resultStr += item;
resultStr += itemArray[i];
}
resultStr += itemStr + "\t";
resultStr += item;
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
resultStr += itemArray[itemsize-1];
}
else{
var addtimes = 0;
var isadd = 0;
for(var i=1; i < itemsize-1; i++){
isadd++;
if(addtimes == 0){
if(itemArray[i].indexOf(id)!= -1){
resultStr += itemStr + "\t";
addtimes = 1;
}
}
resultStr += item;
resultStr += itemArray[i];
}
if(isadd == 0){
if(addtimes == 0){
if(itemArray[i].indexOf(id)!= -1){
resultStr += itemStr + "\t";
addtimes = 1;
}
}
}
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
resultStr += item;
resultStr += itemArray[itemsize-1];
}
}
}
// <20><>1<EFBFBD><31><EFBFBD><EFBFBD>ʱ
else{
resultStr += datatype;
resultStr += timesArray[0];
resultStr += dataTimestr;
// item Ԫ<><D4AA>
var itemArray = timesArray[1].split(item);
var itemsize = itemArray.length;
var nowDate = new Date();
// itemԪ<6D><D4AA>
var itemStr = "<item id=\""+id+"_"+version+"\">\n";
itemStr += "\t\t\t\t<name>"+name+"</name>\n";
itemStr += "\t\t\t\t<collecttime>"+collecttime+"</collecttime>\n";
itemStr += "\t\t\t\t<time>"+nowDate.getFullYear()+"-"+(nowDate.getMonth()+1)+"-"+nowDate.getDate()+" "+nowDate.getHours()+":"+nowDate.getMinutes()+"</time>\n";
itemStr += "\t\t\t\t<province>"+province+"</province>\n";
itemStr += "\t\t\t\t<city>"+city+"</city>\n";
itemStr += "\t\t\t\t<county>"+county+"</county>\n";
itemStr += "\t\t\t\t<system>"+system+"</system>\n";
itemStr += "\t\t\t\t<version>"+version+"</version>\n";
itemStr += "\t\t\t\t<path>"+realpath+"</path>\n";
itemStr += "\t\t\t\t<areacode>"+areacode+"</areacode>\n";
itemStr += "\t\t\t\t<systemcode>"+systemcode+"</systemcode>\n";
itemStr += "\t\t\t\t<contacts>"+contacts+"</contacts>\n";
itemStr += "\t\t\t\t<phone>"+phone+"</phone>\n";
itemStr += "\t\t\t\t<type>"+type+"</type>\n\t\t\t"+itemEnd+"\n\t\t";
// <20><><EFBFBD> <20><> resultStr
// û<><C3BB> item<65><6D> itemsize ==1
if(itemsize ==1){
var dataTimebeginstr = itemArray[0].split(dataTimeEndstr);
resultStr += dataTimebeginstr[0];
resultStr = resultStr + "\t" + itemStr;
resultStr += dataTimeEndstr;
for(var i = 1; i < dataTimebeginstr.length;i++){
resultStr += dataTimebeginstr[i];
}
}
// <20><> item<65><6D>
else{
resultStr += itemArray[0];
if(version == 1){
for(var i=1; i < itemsize-1; i++){
resultStr += item;
resultStr += itemArray[i];
}
resultStr += itemStr+"\t";
resultStr += item;
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
resultStr += itemArray[itemsize-1];
}
else{
var addtimes = 0;
var isadd = 0;
for(var i=1; i < itemsize-1; i++){
isadd++;
if(addtimes == 0){
if(itemArray[i].indexOf(id)!= -1){
resultStr += itemStr + "\t";
addtimes = 1;
}
}
resultStr += item;
resultStr += itemArray[i];
}
if(isadd == 0){
if(addtimes == 0){
if(itemArray[i].indexOf(id)!= -1){
resultStr += itemStr + "\t";
addtimes = 1;
}
}
}
// itemArray[itemsize-1]: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></dataTimes>
resultStr += item;
resultStr += itemArray[itemsize-1];
}
}
//Ȼ<><C8BB><EFBFBD><EFBFBD>ϵ<EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD>
resultStr += dataTimestr;
resultStr += timesArray[2];
}
//<2F><><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD>
resultStr += datatype;
resultStr += typeArray[2];
}
console.log("-----------------------------------------------");
console.log(resultStr);
console.log(typeof resultStr);
// д<><D0B4><EFBFBD>ļ<EFBFBD>
fs.writeFile(dataDetailPath, resultStr, function(err){
if(err)
console.log(err);
else
console.log('has finished');
});
}
});
}
function savehuizong(collecttime, type, id, name, realpath, fakename){
var typestr = "id=\""+type+"\"";
var data = fs.readFileSync(dataPath, "utf-8");
data = data.toString();
var node_arr = data.split("<node");
var node_arr_size = node_arr.length;
//遍历每个节点
for (var i = 1; i < node_arr_size; i++) {
if(node_arr[i] == undefined ){
continue;
}
if(node_arr[i].indexOf(typestr) != -1){
var tem_arr = node_arr[i].split("</node");
var nodeData = "\t<node id=\""+type+"_"+id+"\" name=\""+name+"\" fakename=\""+fakename+"\" path=\""+realpath+"\" time=\""+collecttime+"\"></node>\n\t";
var temhuizonglastSize = tem_arr.length ;
//判断有多少</node>
if (temhuizonglastSize <= 2) {
if(temhuizonglastSize == 2 && tem_arr[1].indexOf(">") != -1){
node_arr[i] = tem_arr[0]+nodeData + "</node>";
}
else{
node_arr[i] = tem_arr[0]+nodeData;
}
}
else{
node_arr[i] = tem_arr[0]+nodeData;
var nodestrtem = "";
for (var k = 1; k < temhuizonglastSize; k++) {
nodestrtem = nodestrtem + "\n</node>";
}
node_arr[i] = node_arr[i] + nodestrtem;
}
break;
}
}
var result_str = node_arr[0];
for (var j = 1; j < node_arr_size; j++) {
result_str = result_str +"<node"+ node_arr[j];
}
fs.writeFileSync(dataPath, result_str);
}
exports.getVersionPath = getVersionPath;
exports.mkdataForPage = mkdataForPage;
exports.saveByIdToXml = saveByIdToXml;
exports.savehuizong = savehuizong;