throw new TinkerPatchException("Parse android manifest error!"); } catch (DocumentException e) { e.printStackTrace(); throw new TinkerPatchException("Parse android manifest by dom4j error!"); } catch (IOException e) {
e2.initCause(e); if (verbose) { e2.printStackTrace();
public DOM4JUtils(InputStream inputStream) { try { // document = reader.read(new // ByteArrayInputStream(xml.getBytes("UTF-8"))); document = new SAXReader().read(inputStream); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public DOM4JUtils(URL url) { try { document = new SAXReader().read(url); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * @param url * The URL object */ public static void read(File file) { // TODO Auto-generated constructor stub try { xmlFile = file; document = new SAXReader().read(file); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * @param inputSource * the xml object 1. if it's a xml file : new * ByteArrayInputStream(xmlfile.getBytes("UTF-8")) 2. if it's * inputstream: just past it; * @return */ public static void read(InputSource inputSource) { try { document = new SAXReader().read(inputSource); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public DOM4JUtils(String xmlfile) { try { // document = reader.read(new // ByteArrayInputStream(xml.getBytes("UTF-8"))); document = new SAXReader().read(new ByteArrayInputStream(xmlfile.getBytes("UTF-8"))); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * 读取xml,加载到dom */ public void reloadDom() { SAXReader reader = new SAXReader(); try { document = reader.read(new File(ConstantsTools.PATH_CONFIG)); } catch (DocumentException e) { e.printStackTrace(); logger.error("Read config xml error:" + e.toString()); } }
public static Video getVideo(File file) { try { SAXReader reader = new SAXReader(); Document doc = reader.read(file);; return parseXml(doc); } catch (DocumentException e) { e.printStackTrace(); } return null; }
private Document readPOM() throws IOException { try { return xmlReader.read(latest.resolvePOM()); } catch (DocumentException e) { System.err.println("** Can't parse POM for "+artifactId); e.printStackTrace(); return null; } }
public static Video getVideo(String url) { try { SAXReader reader = new SAXReader(); Document doc = reader.read(url); return parseXml(doc); } catch (DocumentException e) { e.printStackTrace(); } return null; }
public String getType() { SAXReader saxReader = new SAXReader(); ByteArrayInputStream input = new ByteArrayInputStream(Message.getBytes()); Document document = null; try { document = saxReader.read(input); } catch (DocumentException ex) { ex.printStackTrace(System.out); } Element root = document.getRootElement(); Element tmp = root.element(MessageFields.MESSAGE_TYPE); return tmp.getText(); }
@RequestMapping("callback/{appid}") @PostMapping(produces = "application/xml; charset=UTF-8") public String callbackMsg(@RequestBody String requestBody, @PathVariable String appid){ System.out.println(appid); System.out.println(requestBody); try { JsonObject jsonData= Xml2JsonUtil.xml2Json(requestBody); System.out.println(jsonData); } catch (DocumentException e) { e.printStackTrace(); } return "success"; }
public XmlKit(String filePath) { String xmlPath = XmlKit.class.getResource(filePath).toString(); if (xmlPath.substring(5).indexOf(":") > 0) { // 路径中含有:分隔符,windows系统 xmlPath = xmlPath.substring(6); } else { xmlPath = xmlPath.substring(5); } SAXReader reader = new SAXReader(); try { reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); this.document = reader.read(new File(xmlPath)); } catch (SAXException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } }
protected List<String> getSecurityRoles() { List<String> roles = new ArrayList<String>(); ServletContext sc = this.getServletContext(); InputStream is = sc.getResourceAsStream("/WEB-INF/web.xml"); try { SAXReader reader = new SAXReader(); Document doc = reader.read(is); Element webApp = doc.getRootElement(); // Type safety warning: dom4j doesn't use generics List<Element> roleElements = webApp.elements("security-role"); for (Element roleEl : roleElements) { roles.add(roleEl.element("role-name").getText()); } } catch (DocumentException e) { e.printStackTrace(); } return roles; }
public static void main(String[] args) throws SAXException { String xml = "<root><item><errorCode>1</errorCode><errorDescription></errorDescription></item>"+"<item><errorCode>2</errorCode><errorDescription></errorDescription></item></root>"; SAXReader reader = new SAXReader(); Document doc = null; try { doc = reader.read(new ByteArrayInputStream(xml.getBytes())); @SuppressWarnings("unchecked") List<Element> list = doc.selectNodes("/root/item"); for(Element el : list){ Element errorCode = (Element) el.selectNodes("errorCode").get(0); Element errorDescription = (Element) el.selectNodes("errorDescription").get(0); System.out.println(errorCode.getText() + " : " + errorDescription.getText()); } }catch (DocumentException e) { e.printStackTrace(); } }
public static void main(String[] args) { XMLDataServerConfigureLoader loader = new XMLDataServerConfigureLoader("dataserver.xml"); try { loader.load(); } catch (DocumentException e) { e.printStackTrace(); } }
@Override public void onResponse(Call call, Response response) throws IOException { Document doc = null; try { doc = DocumentHelper.parseText(response.body().string()); } catch (DocumentException e) { e.printStackTrace(); } Element root = doc.getRootElement(); String recCode = root.elementText("code"); String recMsg = root.elementText("msg"); listener.onSuccess(recCode, recMsg, String.valueOf(smsCode)); Log.d(TAG,"-----验证码:"+smsCode); } });
/** * 获取授权的Appid * @param xml * @return */ String getAuthorizerAppidFromXml(String xml) { Document doc; try { doc = DocumentHelper.parseText(xml); Element rootElt = doc.getRootElement(); String toUserName = rootElt.elementText("ToUserName"); return toUserName; } catch (DocumentException e) { e.printStackTrace(); } return null; }
public static String formatXml(String xml) { StringUtil.validateString(xml); String result = xml; Document doc; try { doc = DocumentHelper.parseText(xml); result = XmlUtil.dumpToString(doc, true); } catch (DocumentException e) { e.printStackTrace(); } return result; }