不规则xml导出







  
    
             
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
       
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
    
    
            
      		
      		
            
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      

    
    
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
    
    
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
    
    

      
      
      
      
      
      
      
      
      
      
      
      

    
    
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
    
    
      
      
      
      
      
    
    
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
    
    
      
      
      
      
      
      
      
      
      
    
    
      
    
    
      
      
      
      
    
    
      
    
  
  
    
      
      
      
      
    
    
      		
      		
      		
      		
      		
          
    
    
      
      
      
      
    
    
	  

    
    
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
            
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      

    
    
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
          
                  
    
  

 上面是要导出的数据

 

 

下面演示怎么截取数据导入

        protected void btnImport_Click(object sender, EventArgs e)
        {//导入
            //声明集合
            List processList = new List();
            List packageList = new List();
            List reportList = new List();

            string xmlFilePath = Server.MapPath("DrawDocument.xml");
            XmlDocument doc = new XmlDocument();
            doc.Load(xmlFilePath);

            XmlNodeList drawNodeList = doc.SelectNodes("/categorys");

            if (drawNodeList != null)
            {
                foreach (XmlNode drawNode in drawNodeList)
                {
                    string sName = drawNode.Attributes["name"].Value;
                    Response.Write("第一层 " + sName + "
"); //XmlNode categoryNode = drawNode.SelectSingleNode("Category"); XmlNodeList categoryNodeList = drawNode.SelectNodes("Category"); //XmlNodeList categoryNodeList = drawNode.ChildNodes; if (categoryNodeList != null) { foreach (XmlNode categoryNode in categoryNodeList) { Response.Write("  第二层 编号:" + categoryNode.Attributes["name"].Value + " Title:" + categoryNode.Attributes["title"].Value + "
"); EP_ND_ServiceProcess processModel = new EP_ND_ServiceProcess(); processModel.Id = categoryNode.Attributes["name"].Value; processModel.ServiceProcessName = categoryNode.Attributes["title"].Value; processModel.Visible = Convert.ToBoolean(categoryNode.Attributes["visible"].Value); processModel.Sort = int.Parse(categoryNode.Attributes["group"].Value); processList.Add(processModel); XmlNodeList categoryChildNodeList = categoryNode.SelectNodes("category"); if (categoryChildNodeList != null) { foreach (XmlNode categoryChildNode in categoryChildNodeList) { string categoryTitle = categoryChildNode.Attributes["title"].Value; Response.Write("    第三层 Title:" + categoryTitle + "
"); EIP_ND_ServicePackage package = new EIP_ND_ServicePackage(); package.Id = categoryChildNode.Attributes["name"].Value; package.EP_ServiceProcessId = processModel.Id; package.ServiceName = categoryChildNode.Attributes["title"].Value; package.Visible = Convert.ToBoolean(categoryChildNode.Attributes["visible"].Value); package.Sort = int.Parse(categoryChildNode.Attributes["group"].Value); packageList.Add(package); XmlNodeList sonNodeList = categoryChildNode.ChildNodes; if (sonNodeList != null) { foreach (XmlNode item in sonNodeList) { string id = item.Attributes["name"].Value; string title = item.Attributes["title"].Value; //if (item.Attributes["name"] != null) //{ // id = item.Attributes["name"].Value; //} //else //{ // id = new Guid().ToString(); //} Response.Write("      第四层 id:" + id + " title:" + title + "
"); EIP_ND_Report report = new EIP_ND_Report(); report.id = id; report.EIP_Id = package.Id; report.ReportName = title; report.CreateTime = DateTime.Now; report.Url = item.Attributes["href"].Value; report.Role = item.Attributes["role"].Value; report.Visible = Convert.ToBoolean(item.Attributes["visible"].Value); if (item.Attributes["PositiveNegative"] != null) report.TheSelected = true; else report.TheSelected = false; reportList.Add(report); } } } } } } } } //插入事物 //TranAddEP_ServiceProcess(processList); //TranAddEIP_ServicePackage(packageList); //TranAddEIP_Report(reportList); }

 

效果截图

不规则xml导出_第1张图片

 

常用的操作xml的总结

 

源代码下载

转载于:https://www.cnblogs.com/suntanyong88/p/4484166.html

你可能感兴趣的:(不规则xml导出)