向word生成的xml中插入xml

List list=element.getParent().getParent().getParent().elements();
     Properties properties=new Properties();
  FileInputStream inputStream=new FileInputStream(ServletActionContext.getRequest().getRealPath("")+"\\template\\"+eletext.substring(2,eletext.length() - 1)+".properties");
  properties.load(inputStream);
  inputStream.close();
  List sortList=new ArrayList();//有顺序的信息
  for(Object o:properties.keySet()){
   sortList.add(o.toString());
  }
  if(!sortList.isEmpty()){
   sortList=sortProp(sortList);
  }

String xmlDocument="";
  String xmlrPr="";
  String xmlurPr="";
  String xmlpPr=""+""+xmlrPr+"";
  String xmlP="";
  String xmlPreserve="  ";
  String no="";
  for(String str:sortList){
   String label=new String(str.substring(str.lastIndexOf(".")+1).getBytes("ISO8859-1"),"GBK");
   String profix=properties.get(str).toString().substring(properties.get(str).toString().lastIndexOf(".")-2,properties.get(str).toString().lastIndexOf(".")-1);
   if(!no.equals(str.substring(0,1))){
    no=str.substring(0,1);
    if(!no.equals("1")){
     xmlDocument+="
";
    }
    xmlDocument+=xmlP+xmlpPr+""+xmlrPr+""+label+":"+""+""+""+xmlurPr+""+dataMap.get(profix+label)+""+"";
   }else{
    xmlDocument+=xmlPreserve;
    xmlDocument+=""+xmlrPr+""+label+":"+""+""+""+xmlurPr+""+dataMap.get(profix+label)+""+"";
   }
  }
  xmlDocument+="";
  xmlDocument+="
";
     Document doc=XmlBuilder.createXMLDoc(xmlDocument);
     List pList=doc.selectNodes("//w:p");
     i--;
     list.remove(i);
     for(Object o:pList){
      Element e=(Element)o;
      list.add(i,e.createCopy());
      i++;
     }

你可能感兴趣的:(向word生成的xml中插入xml)