示例#1
0
  public static void commonReader() {
    XMLCommonReader xcr = new XMLCommonReader();
    // 设置层次结构
    //		List xmlLevelList = new ArrayList(3);
    //
    //		xmlLevelList.add(0, "root/BaseInfo");
    //		xmlLevelList.add(1, "root/ProductInfo/BussinessInfo");
    //		xmlLevelList.add(2, "root/ProductInfo/BussinessInfo/BusiList");

    List xmlLevelList = new ArrayList(1);
    xmlLevelList.add(0, "Root");
    xcr.setXMLLevelList(xmlLevelList);

    ReadFile rf = new ReadFile();
    String xmlstr = rf.getFileContent("d:/我的桌面/addd.xml", "UTF-8");
    try {
      xcr.analysisXML(xmlstr);
    } catch (Exception e) {
      e.printStackTrace();
    }
    String bizid = xcr.getXmlDomElementLeafNodeValue((String) xmlLevelList.get(0), "ProductID", 0);
    System.out.println(bizid);
    //		List rootList = getXmlLevelItemMap(xcr, (String) xmlLevelList.get(0));
    //		List baseList = getXmlLevelItemMap(xcr, (String) xmlLevelList.get(1));
    //		List list = getXmlLevelItemList(xcr, (String) xmlLevelList.get(2));
  }
示例#2
0
  public static void testchkXmlFrame() {
    XMLCommonReader xcr = new XMLCommonReader();
    XMLCommonReader xcr_source = new XMLCommonReader();
    // 设置层次结构
    //		List<String> xmlLevelList = new ArrayList<String>(2);
    //
    //		xmlLevelList.add(0, "ContractRoot/TcpCont");
    //		xmlLevelList.add(1, "ContractRoot/SvcCont/BusEvent/CustomerInfo");
    //
    //		xcr.setXMLLevelList(xmlLevelList);
    //		xcr_source.setXMLLevelList(xmlLevelList);

    ReadFile rf = new ReadFile();
    String xmlstr = rf.getFileContent("d:/custinfo_chk_receive.xml", "UTF-8");
    String xmlstr_source = rf.getFileContent("d:/aaaaa.xml", "UTF-8");
    try {
      xcr.analysisXML(xmlstr);
      xcr_source.analysisXML(xmlstr_source);
    } catch (Exception e) {
      e.printStackTrace();
    }

    //		chkXmlFrame(xmlLevelList,xcr,xcr_source);
  }