List of usage examples for org.dom4j DocumentHelper parseText
public static Document parseText(String text) throws DocumentException
parseText
parses the given text as an XML document and returns the newly created Document.
From source file:com.kingmed.dp.mail.util.XMLHandler.java
public static Map<String, String> transSimpleXmltoMap(String xmlInfo) throws DocumentException { Document doc = DocumentHelper.parseText(xmlInfo); // xml Map<String, String> map = new HashMap<String, String>(); Element rootElt = doc.getRootElement(); @SuppressWarnings("rawtypes") Iterator iter = rootElt.elementIterator(); while (iter.hasNext()) { Element dataElement = (Element) iter.next(); map.put(dataElement.getName(), dataElement.getText()); }/*from www .j a v a2 s . co m*/ return map; }
From source file:com.kingmed.dp.mail.util.XMLHandler.java
@SuppressWarnings("unchecked") public static List<Node> query(String xml, String xpath) throws DocumentException { List<Node> nodes = null; Document doc = DocumentHelper.parseText(xml); nodes = doc.selectNodes(xpath);//from w ww. j a v a2s. co m return nodes; }
From source file:com.kingmed.yuyt.bean.ReportResponseBean.java
@Override public void process(Exchange msg) throws Exception { String record = msg.getIn().getBody(String.class); Document doc = DocumentHelper.parseText(record); Map<String, Object> map = new HashMap<String, Object>(); String report_status = doc.selectSingleNode(Constants.EXP_REPORT_STATUS).getText(); String report_detail_status = doc.selectSingleNode(Constants.EXP_REPORT_DETAIL_STATUS).getText(); String isReimbu = doc.selectSingleNode(Constants.EXP_RESPONSE_IS_ISREIMBU).getText(); String speStatus = doc.selectSingleNode(Constants.EXP_RESPONSE_SPE_STATUS).getText(); String reportFile = ""; String isPositive = Constants.POSITIVE_X; String docId = doc.selectSingleNode(Constants.EXP_DOC_ID).getText(); String subCompany = doc.selectSingleNode(Constants.EXP_SUB_COMPANY).getText(); String hospitial = doc.selectSingleNode(Constants.EXP_HOSPITAL).getText(); String kmBarcode = doc.selectSingleNode(Constants.EXP_KM_BARCODE).getText(); String spec_doc_id = doc.selectSingleNode(Constants.EXP_SPEC_DOC_ID).getText(); map.put("enable", Constants.ENABLE_YES); map.put("msg_type", Constants.MSG_TYPE_QUERY_REPORT_RESPONSE); map.put("doc_id", docId);// ? id map.put("spec_doc_id", spec_doc_id);// id map.put("sub_company", subCompany); map.put("hospital", hospitial); map.put("km_barcode", kmBarcode); map.put("direction", Constants.MSG_IN); map.put("msg", record); map.put("create_time", new Timestamp(System.currentTimeMillis())); map.put("status", Constants.MSG_STATUS_NEW);// ? map.put("report_status", report_status); map.put("report_detail_status", report_detail_status); map.put("IsReimbu", isReimbu); map.put("speStatus", speStatus); // ???/*from w w w .j a v a 2 s. c o m*/ if (report_status.equals(Constants.LIS_S)) { reportFile = doc.selectSingleNode(Constants.EXP_REPORT_FILE).getText(); isPositive = this.checkPositive(doc);// ? } // ???? if (Constants.LIS_ISREIMBU_Y.equals(isReimbu)) { reportFile = doc.selectSingleNode(Constants.EXP_REPORT_FILE).getText(); } map.put("reportfile", reportFile); map.put(Constants.POSITIVE, isPositive); msg.getOut().setBody(map); }
From source file:com.kingmed.yuyt.util.XMLHandler.java
public static Map<String, String> transXmltoMapForSpec(String xmlInfo) throws DocumentException { Document doc = DocumentHelper.parseText(xmlInfo); // xml Map<String, String> map = new HashMap<String, String>(); Element rootElt = doc.getRootElement(); Iterator iter = rootElt.elementIterator(); while (iter.hasNext()) { Element dataElement = (Element) iter.next(); map.put(dataElement.getName(), dataElement.getText()); }/* www. j a va2s. co m*/ Element e = (Element) (rootElt.element("specimen").elements().get(0)); map.put("specimen", e.asXML()); return map; }
From source file:com.kingmed.yuyt.util.XMLHandler.java
public static Map<String, Object> transXmltoMapForReport(String xmlInfo) throws DocumentException { Document doc = DocumentHelper.parseText(xmlInfo); // xml Map<String, Object> map = new HashMap<String, Object>(); Element rootElt = doc.getRootElement(); Iterator iter = rootElt.elementIterator(); while (iter.hasNext()) { Element dataElement = (Element) iter.next(); map.put(dataElement.getName(), dataElement.getText()); }/*from w ww . ja v a 2 s . co m*/ /* Element e = (Element) (rootElt.element("Data")); String data = ""; if (e != null) { data = ((Element) e.elements().get(0)).asXML(); map.put("Data", "<Data>" + data + "</Data>"); } else { data = xmlInfo; map.put("Data", data); } */ return map; }
From source file:com.kingmed.yuyt.util.XMLHandler.java
public static Map<String, String> transSimpleXmltoMap(String xmlInfo) throws DocumentException { Document doc = DocumentHelper.parseText(xmlInfo); // xml Map<String, String> map = new HashMap<String, String>(); Element rootElt = doc.getRootElement(); Iterator iter = rootElt.elementIterator(); while (iter.hasNext()) { Element dataElement = (Element) iter.next(); map.put(dataElement.getName(), dataElement.getText()); }// w ww. j a v a 2 s.co m return map; }
From source file:com.kingmed.yuyt.util.XMLHandler.java
public static List<Node> query(String xml, String xpath) throws DocumentException { List<Node> nodes = null; Document doc = DocumentHelper.parseText(xml); nodes = doc.selectNodes(xpath);/* w w w. j a va 2 s .c om*/ return nodes; }
From source file:com.lafengmaker.tool.util.XMLDataUtil.java
License:Open Source License
public static Document parseDocument(String sContent) throws Exception { Document doc = null;// ww w.j a v a 2s . c o m doc = DocumentHelper.parseText(sContent); return doc; }
From source file:com.love320.templateparser.label.impl.XMLToLabelImpl.java
License:Apache License
@Override public List<Label> get(String xmlstr) { List<Label> labeList = new ArrayList<Label>(); try {//from w w w. jav a 2 s . co m Document document = DocumentHelper.parseText(xmlstr);//string ?xml Element docroot = document.getRootElement();//?Element List ls = docroot.selectNodes("/root/content/item");//?item for (int i = 0; i < ls.size(); i++) {//?? Element element = (Element) ls.get(i);//? String type = element.attributeValue("type");//? Label label = new Label();// label.setType(type);// label.setTemplate(element.getText());// labeList.add(label);// /* if(type.equals("label")){// logger.info("label:"+element.getText()); }else if(type.equals("symbols")){//? logger.info("symbols:"+element.getText()); }else{// logger.info(element.getText()); } */ } } catch (DocumentException e) { logger.error("DocumentException", e); } return labeList; }
From source file:com.lzw.work.cms.manager.PreCarRegisterManager.java
private String getlsh() { String lsh = null;/*from www .j a v a 2s . c om*/ try { TmriJaxRpcOutAccessServiceStub trias = new TmriJaxRpcOutAccessServiceStub(); TmriJaxRpcOutAccessServiceStub.QueryObjectOut qo = new TmriJaxRpcOutAccessServiceStub.QueryObjectOut(); qo.setJkid("01C24"); qo.setJkxlh( "7F1C0909010517040815E3FF83F5F3E28BCC8F9B818DE7EA88DFD19EB8C7D894B9B9BCE0BFD8D6D0D0C4A3A8D0C5CFA2BCE0B9DCCFB5CDB3A3A9"); qo.setUTF8XmlDoc("<root><QueryCondition></QueryCondition></root>"); qo.setXtlb("01"); String returnXML = trias.queryObjectOut(qo).getQueryObjectOutReturn(); Document doc = DocumentHelper.parseText(returnXML); Element root = doc.getRootElement(); lsh = root.element("body").element("veh").element("lsh").getText(); } catch (RemoteException e) { e.printStackTrace(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } return lsh; }