Example usage for org.dom4j.io SAXReader SAXReader

List of usage examples for org.dom4j.io SAXReader SAXReader

Introduction

In this page you can find the example usage for org.dom4j.io SAXReader SAXReader.

Prototype

public SAXReader() 

Source Link

Usage

From source file:com.fonoster.astive.examples.ws.YahooParser.java

License:Apache License

private SAXReader createXmlReader() {
    Map<String, String> uris = new HashMap<String, String>();
    uris.put("yweather", "http://xml.weather.yahoo.com/ns/rss/1.0");

    DocumentFactory factory = new DocumentFactory();
    factory.setXPathNamespaceURIs(uris);

    SAXReader xmlReader = new SAXReader();
    xmlReader.setDocumentFactory(factory);

    return xmlReader;
}

From source file:com.footprint.server.common.config.ConfigHelper.java

License:Open Source License

private static Document getDocument() {
    try {/*  ww w  .  ja  v a2s . c o  m*/
        if (document == null) {
            File configFile = new ClassPathResource(CONFIG_XML_PATH).getFile();
            document = new SAXReader().read(configFile);
        }

        return document;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.founder.fix.fixflow.core.impl.util.XmlUtil.java

License:Apache License

public static Document read(String fileName) throws DocumentException {
    SAXReader reader = new SAXReader();
    Document document = reader.read(new File(fileName));

    return document;
}

From source file:com.founder.fix.fixflow.core.impl.util.XmlUtil.java

License:Apache License

public static Document read(File file) throws DocumentException {
    SAXReader reader = new SAXReader();
    Document document = reader.read(file);

    return document;
}

From source file:com.founder.fix.fixflow.core.impl.util.XmlUtil.java

License:Apache License

public static Document read(InputStream is) throws DocumentException {
    SAXReader reader = new SAXReader();
    Document document = reader.read(is);

    return document;
}

From source file:com.founder.fix.fixflow.core.impl.util.XmlUtil.java

License:Apache License

public static Document read(URL url) throws DocumentException {
    SAXReader reader = new SAXReader();
    Document document = reader.read(url);

    return document;
}

From source file:com.founder.fix.fixflow.editor.impl.PluginServiceImpl.java

License:Apache License

public void getPluginXml(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    InputStream pluginStream = this.getClass().getClassLoader().getResourceAsStream("plugins.xml");
    Document document = null;/*from  www.j a  va  2  s  . c  om*/
    resp.setContentType("text/xml;charset=utf-8");
    PrintWriter out = resp.getWriter();
    SAXReader reader = new SAXReader();
    try {
        document = reader.read(pluginStream);
        out.print(document.asXML());
    } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.framework.service.logconfig.LogConfigServiceImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Cacheable("logConfig")
public List<LogConfig> getAll() {
    try {/*from w w  w .j a va  2  s  . c  o  m*/
        File shopxxXmlFile = new ClassPathResource("/framework.xml").getFile();
        Document document = new SAXReader().read(shopxxXmlFile);
        List<org.dom4j.Element> elements = document.selectNodes("/framework/logConfig");
        List<LogConfig> logConfigs = new ArrayList<LogConfig>();
        for (org.dom4j.Element element : elements) {
            String logType = element.attributeValue("logType");
            int logLevel = Integer.parseInt((String) element.attributeValue("logLevel"));
            String operatObject = element.attributeValue("operatObject");
            String urlPattern = element.attributeValue("urlPattern");
            LogConfig logConfig = new LogConfig();
            logConfig.setLogType(logType);
            logConfig.setLogLevel(logLevel);
            logConfig.setUrlPattern(urlPattern);
            logConfig.setOperatObject(operatObject);
            logConfigs.add(logConfig);
        }
        return logConfigs;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.funtl.framework.alipay.trade.util.AlipaySubmit.java

License:Apache License

/**
 * ?query_timestamp???//  w  ww . ja  v  a 2s  .  c om
 * ??XML???SSL?
 *
 * @return 
 * @throws IOException
 * @throws DocumentException
 * @throws MalformedURLException
 */
public static String query_timestamp() throws MalformedURLException, DocumentException, IOException {

    //query_timestamp?URL
    String strUrl = PayManager.HTTPS_MAPI_ALIPAY_COM_GATEWAY_DO + "?" + "service=query_timestamp&partner="
            + AlipayConfig.partner + "&_input_charset" + AlipayConfig.input_charset;
    StringBuffer result = new StringBuffer();

    SAXReader reader = new SAXReader();
    Document doc = reader.read(new URL(strUrl).openStream());

    List<Node> nodeList = doc.selectNodes("//alipay/*");

    for (Node node : nodeList) {
        // ?????
        if (node.getName().equals("is_success") && node.getText().equals("T")) {
            // ??
            List<Node> nodeList1 = doc.selectNodes("//response/timestamp/*");
            for (Node node1 : nodeList1) {
                result.append(node1.getText());
            }
        }
    }

    return result.toString();
}

From source file:com.fxdigital.manager.SoftInfoImpl.java

/**
 * ???/*from   w w  w .  j  a  v a 2s. c o  m*/
 * 
 * @return
 */
public String getDeviceType() {
    String type = null;
    String path = getPath();
    if (path == null) {
        return "?";
    }
    File f = new File(path);
    SAXReader reader = new SAXReader();
    try {
        Document doc = reader.read(f);
        Element root = doc.getRootElement();
        type = root.attributeValue("DeviceType");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return type;
}