Example usage for org.dom4j DocumentHelper parseText

List of usage examples for org.dom4j DocumentHelper parseText

Introduction

In this page you can find the example usage for org.dom4j DocumentHelper parseText.

Prototype

public static Document parseText(String text) throws DocumentException 

Source Link

Document

parseText parses the given text as an XML document and returns the newly created Document.

Usage

From source file:com.lzw.work.cms.manager.PreCarRegisterManager.java

public void getCarInfoByCarNumber() {
    try {//from   w  w  w  .ja v a 2 s  .  c  om
        TmriJaxRpcOutAccessServiceStub trias = new TmriJaxRpcOutAccessServiceStub();
        TmriJaxRpcOutAccessServiceStub.QueryObjectOut qo = new TmriJaxRpcOutAccessServiceStub.QueryObjectOut();

        HttpServletRequest request = ServletActionContext.getRequest();

        String hpzl = request.getParameter("hpzl");
        String hphm = request.getParameter("hphm");

        if (hpzl == null || "".equals(hpzl.trim()) || hphm == null || "".equals(hphm.trim())) {
            return;
        }

        qo.setJkid("01C21");
        qo.setJkxlh(
                "7F1C0909010517040815E3FF83F5F3E28BCC8F9B818DE7EA88DFD19EB8C7D894B9B9BCE0BFD8D6D0D0C4A3A8D0C5CFA2BCE0B9DCCFB5CDB3A3A9");
        qo.setUTF8XmlDoc("<root><QueryCondition><hphm>" + hphm + "</hphm><hpzl>" + hpzl
                + "</hpzl></QueryCondition></root>");
        qo.setXtlb("01");

        String returnXML = trias.queryObjectOut(qo).getQueryObjectOutReturn();
        String xml = URLCodeUtil.urlDecode(returnXML);
        Document doc = DocumentHelper.parseText(xml);
        Element root = doc.getRootElement();
        Element dataElecmet = root.element("body").element("veh");

        if (dataElecmet != null) {
            Map<String, String> dataMap = new HashMap<String, String>();
            for (Object o : dataElecmet.elements()) {
                Element element = (Element) o;
                String key = element.getName();
                String value = element.getText();
                dataMap.put(key, value);
            }
            pw.print(JSONObject.fromObject(dataMap));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.lzw.work.cms.manager.PreCarRegisterManager.java

public void getCarInfoByCarNumberConvert() {
    try {/*  w  w w .j  av  a 2 s .  c om*/
        TmriJaxRpcOutAccessServiceStub trias = new TmriJaxRpcOutAccessServiceStub();
        TmriJaxRpcOutAccessServiceStub.QueryObjectOut qo = new TmriJaxRpcOutAccessServiceStub.QueryObjectOut();

        HttpServletRequest request = ServletActionContext.getRequest();

        String hpzl = request.getParameter("hpzl");
        String hphm = request.getParameter("hphm");

        if (hpzl == null || "".equals(hpzl.trim()) || hphm == null || "".equals(hphm.trim())) {
            return;
        }

        qo.setJkid("01C21");
        qo.setJkxlh(
                "7F1C0909010517040815E3FF83F5F3E28BCC8F9B818DE7EA88DFD19EB8C7D894B9B9BCE0BFD8D6D0D0C4A3A8D0C5CFA2BCE0B9DCCFB5CDB3A3A9");
        qo.setUTF8XmlDoc("<root><QueryCondition><hphm>" + hphm + "</hphm><hpzl>" + hpzl
                + "</hpzl></QueryCondition></root>");
        qo.setXtlb("01");

        String returnXML = trias.queryObjectOut(qo).getQueryObjectOutReturn();
        String xml = URLCodeUtil.urlDecode(returnXML);
        Document doc = DocumentHelper.parseText(xml);
        Element root = doc.getRootElement();
        Element dataElecmet = root.element("body").element("veh");

        if (dataElecmet != null) {
            Map<String, String> dataMap = new HashMap<String, String>();
            for (Object o : dataElecmet.elements()) {
                Element element = (Element) o;
                String key = element.getName();
                String value = element.getText();

                dataMap.put(key, CommonUtil.convertCode(key, value));
            }
            String clxh = (String) dataMap.get("clxh");
            if (clxh != null) {
                String ggbh = trafficDBManager.getFirstGGBH(clxh);
                dataMap.put("ggbh", ggbh);
            }

            pw.print(JSONObject.fromObject(dataMap));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.lzw.work.cms.manager.PreCarRegisterManager.java

public void getCarInfo2ByCarNumber() {
    try {// www  . ja  v  a2s  .c  o m
        TmriJaxRpcOutAccessServiceStub trias = new TmriJaxRpcOutAccessServiceStub();
        TmriJaxRpcOutAccessServiceStub.QueryObjectOut qo = new TmriJaxRpcOutAccessServiceStub.QueryObjectOut();

        HttpServletRequest request = ServletActionContext.getRequest();

        String hpzl = request.getParameter("hpzl");
        String hphm = request.getParameter("hphm");
        String sf = request.getParameter("sf");
        System.out.println("sf" + sf);
        if (sf != null) {
            sf = URLEncoder.encode(sf, "UTF-8");

        }
        System.out.println("sf" + sf);

        if (hpzl == null || "".equals(hpzl.trim()) || hphm == null || "".equals(hphm.trim())) {
            return;
        }

        qo.setJkid("01C49");
        qo.setJkxlh(
                "7F1C0909010517040815E3FF83F5F3E28BCC8F9B818DE7EA88DFD19EB8C7D894B9B9BCE0BFD8D6D0D0C4A3A8D0C5CFA2BCE0B9DCCFB5CDB3A3A9");
        qo.setUTF8XmlDoc("<root><QueryCondition><hphm>" + hphm + "</hphm><hpzl>" + hpzl + "</hpzl><sf>" + sf
                + "</sf></QueryCondition></root>");
        qo.setXtlb("01");

        String returnXML = trias.queryObjectOut(qo).getQueryObjectOutReturn();
        String xml = URLCodeUtil.urlDecode(returnXML);
        Document doc = DocumentHelper.parseText(xml);
        Element root = doc.getRootElement();
        System.out.println(root.asXML());
        Element dataElecmet = root.element("body").element("veh");

        if (dataElecmet != null) {
            Map<String, String> dataMap = new HashMap<String, String>();
            for (Object o : dataElecmet.elements()) {
                Element element = (Element) o;
                String key = element.getName();
                String value = element.getText();

                dataMap.put(key, CommonUtil.convertCode(key, value));
            }
            String clxh = (String) dataMap.get("clxh");
            if (clxh != null) {
                String ggbh = trafficDBManager.getFirstGGBH(clxh);
                dataMap.put("ggbh", ggbh);
            }

            pw.print(JSONObject.fromObject(dataMap));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.magicpwd._util.Card.java

License:Open Source License

public java.io.File exportPng(java.io.File src, java.io.File dst) throws Exception {
    java.io.InputStream stream = new java.io.FileInputStream(src);
    StringBuffer buffer = trim(stream);
    return draw(DocumentHelper.parseText(buffer.toString()), dst);
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.message.MMXPubSubItem.java

License:Apache License

public MMXPubSubItem(String appId, String topicName, String itemId, JID publisher, String payload) {
    this.appId = appId;
    this.topicName = topicName;
    this.itemId = itemId;
    this.publisher = new MMXItemPublisher(publisher);
    try {//from  ww w.j a  va2s  .com
        Document document = DocumentHelper.parseText(payload);
        parsePayload(document.getRootElement());
    } catch (Exception e) {

    }
}

From source file:com.magnet.mmx.server.plugin.mmxmgmt.message.MMXPubSubItemChannel.java

License:Apache License

public MMXPubSubItemChannel(String channelName, String itemId, JID publisher, String payload) {
    //    public MMXPubSubItemChannel(String appId, String channelName, String itemId, JID publisher, String payload) {
    //      this.appId = appId;
    this.channelName = channelName;
    this.itemId = itemId;
    this.publisher = new MMXItemPublisher(publisher);
    try {//ww w. ja  v a 2 s .  co  m
        Document document = DocumentHelper.parseText(payload);
        parsePayload(document.getRootElement());
    } catch (Exception e) {

    }
}

From source file:com.mg.framework.support.ui.UIProducer.java

License:Open Source License

private static Form doProduceFormFromString(String body, RuntimeMacrosLoader runtimeMacrosLoader) {
    try {// w w  w  .  jav  a2 s  . c  o m
        return parseFormDescription(DocumentHelper.parseText(body), null, runtimeMacrosLoader);
    } catch (DocumentException e) {
        throw new ApplicationException(e);
    }
}

From source file:com.mg.framework.support.ui.UIProducer.java

License:Open Source License

public static Document performDocument(Document document, RuntimeMacrosLoader runtimeMacrosLoader) {
    logger.debug("Original form descriptor:\n".concat(document.asXML()));
    Document result = DocumentFactory.getInstance().createDocument(document.getXMLEncoding());
    result.setDocType(document.getDocType());
    result.setRootElement(copyElement(document.getRootElement(), runtimeMacrosLoader));
    result.getRootElement().addNamespace(document.getRootElement().getNamespacePrefix(),
            document.getRootElement().getNamespaceURI());
    try {/*from w w w . j  a  va2s . co  m*/
        //?   ?,  ?  ? namespaces
        result = DocumentHelper.parseText(result.asXML());
        logger.debug("Finished form descriptor:\n".concat(result.asXML()));
        return result;
    } catch (DocumentException e) {
        throw new ApplicationException(e);
    }
}

From source file:com.mindquarry.desktop.pool.PoolBase.java

License:Open Source License

public Map<String, Document> getEntries() {
    Map<String, Document> results = new HashMap<String, Document>();

    File[] files = poolFolder.listFiles();
    for (File file : files) {
        String id = file.getName();

        try {//from w w w. j av a 2 s.c o  m
            StringBuffer contents = new StringBuffer();
            BufferedReader input = new BufferedReader(new FileReader(file));
            String line = null;

            while ((line = input.readLine()) != null) {
                contents.append(line);
            }
            Document doc = DocumentHelper.parseText(contents.toString());
            results.put(id, doc);
        } catch (Exception e) {
            log.error("Error while fetching pool entries.", e); //$NON-NLS-1$
        }
    }
    return results;
}

From source file:com.mingsoft.weixin.util.XmlUtils.java

License:Open Source License

/**
 * ?xml??document?/*from w  ww .j  a va2  s. c om*/
 * 
 * @param str
 *            
 * @return ??Documentnull
 */
public static Document stringToXml(String str) {
    try {
        return DocumentHelper.parseText(str);
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    return null;
}