List of usage examples for org.dom4j Node getText
String getText();
Returns the text of this node.
From source file:com.googlecode.fascinator.redbox.sru.SRUResponse.java
License:Open Source License
/** * <p>Default Constructor. Extract some basic information.</p> * /*from ww w .ja v a2 s . c om*/ * @param searchResponse A parsed DOM4J Document * @throws SRUException If any of the XML structure does not look like expected */ @SuppressWarnings("unchecked") public SRUResponse(Document searchResponse) throws SRUException { // Results total Node number = searchResponse.selectSingleNode("//srw:numberOfRecords"); if (number == null) { throw new SRUException("Unable to get result numbers from response XML."); } totalRecords = Integer.parseInt(number.getText()); log.debug("SRU Search found {} results(s)", totalRecords); // Results List if (totalRecords == 0) { resultsList = new ArrayList<Node>(); } else { resultsList = searchResponse.selectNodes("//srw:recordData"); } recordsReturned = resultsList.size(); }
From source file:com.googlecode.starflow.engine.xml.NodeUtil.java
License:Apache License
/** * ?elementpathString/*from w w w. jav a2 s . co m*/ * * @param element * @param path * @return String */ public static String getNodeStringValue(Element element, String path) { Node node = element.selectSingleNode(path); return node.getText(); }
From source file:com.googlecode.starflow.engine.xml.NodeUtil.java
License:Apache License
/** * ?elementpathint//from ww w .j ava 2s . co m * * @param element * @param path * @return */ public static int getNodeIntValue(Element element, String path) { Node node = element.selectSingleNode(path); if (node != null) { if (StringUtils.hasText(node.getText())) return Integer.parseInt(node.getText()); else return 0; } else return 0; }
From source file:com.googlecode.starflow.engine.xml.NodeUtil.java
License:Apache License
/** * ?elementpathlong/* w w w . ja va2 s.com*/ * * @param element * @param path * @return */ public static long getNodeLongValue(Element element, String path) { Node node = element.selectSingleNode(path); if (node != null) { if (StringUtils.hasText(node.getText())) return Long.parseLong(node.getText()); else return 0l; } else return 0l; }
From source file:com.googlecode.starflow.engine.xml.NodeUtil.java
License:Apache License
/** * ?elementpathdouble/*from w w w . ja va 2 s. c om*/ * * @param element * @param path * @return */ public static double getNodeDoubleValue(Element element, String path) { Node node = element.selectSingleNode(path); if (node != null) { if ("".equals(node.getText())) return 0d; else return Double.parseDouble(node.getText()); } else return 0d; }
From source file:com.iisigroup.cap.utils.CapXmlUtil.java
License:Open Source License
/** * ? xPath text/*from w w w .j a v a 2 s .co m*/ * * @param document * xmlDocument * @param xPath * xpath * @return String */ public static String getDocSingleNodeTextByXPath(Document document, String xPath) { try { Node node = document.selectSingleNode(xPath); if (node != null) { return node.getText(); } else { return null; } } catch (Exception e) { LOGGER.error(e.getMessage(), e); return null; } }
From source file:com.kingmed.yuyt.bean.ReportResponseBean.java
/** * /*from www . j a va2 s .com*/ * * @param map LIS??LIS???? queryRequestDetail * @throws DocumentException */ public String checkPositive(Document doc) throws DocumentException { String re = Constants.POSITIVE_X; String expDataRow = "/response/report_detail/Data/Data_Row"; String expNaturalItem = "/response/report_detail/Data/Data_Row[1]/NaturalItemName";// ?? String cp = "/response/report_detail/Data/Data_Row[NaturalItem=5105]";// ?? String cp1 = "/response/report_detail/Data/Data_Row[NaturalItem=5903]";// ?? String expResult = "/response/report_detail/Data/Data_Row/Result"; String result = null; Node node = doc.selectSingleNode(expNaturalItem); String naturalItemName = node.getText(); String singleItemName = null; List<Element> cpElms = doc.selectNodes(cp); if (cpElms != null && cpElms.size() > 0) { re = checkPositive4CP(doc, expResult); return re; } cpElms = doc.selectNodes(cp1); if (cpElms != null && cpElms.size() > 0) { re = checkPositive4CP(doc, expResult); return re; } if (naturalItemName.contains("?HPV")) {// ?HPV re = Constants.POSITIVE_N; result = doc.selectSingleNode(expResult).getText(); if (result.contains("")) { re = Constants.POSITIVE_Y; } return re; } if (naturalItemName.contains("HPV")) {// ?HPV re = Constants.POSITIVE_N; List<Element> es = doc.selectNodes(expDataRow); for (Element e : es) { singleItemName = e.element("SingleItemName").getText(); result = e.element("Result").getText(); if (this.hpvHighRish17.contains(singleItemName) && result.contains("")) { re = Constants.POSITIVE_Y; return re; } } } return re; }
From source file:com.lafengmaker.tool.util.XMLDataUtil.java
License:Open Source License
public static long getNodeTextAsLong(Node node, long defaultValue) { if (node != null) { String nodeValue = node.getText(); return Long.parseLong(nodeValue); } else {// www. ja v a2 s .c o m return defaultValue; } }
From source file:com.lafengmaker.tool.util.XMLDataUtil.java
License:Open Source License
/** * /*w w w. j a va 2 s . c o m*/ * @param node * @param xPath * @param defaultValue * @return */ public static long getNodeTextAsLong(Node node, String xPath, long defaultValue) { long returnValue = 0; if (node != null) { Node tempNode = node.selectSingleNode(xPath); if (tempNode != null) { String nodeValue = tempNode.getText(); returnValue = parseLong(nodeValue, defaultValue); } else { returnValue = defaultValue; } } else { returnValue = defaultValue; } return returnValue; }
From source file:com.lafengmaker.tool.util.XMLDataUtil.java
License:Open Source License
public static int getNodeTextAsInt(Node node, int defaultValue) { if (node != null) { String nodeValue = node.getText(); return parseInt(nodeValue, defaultValue); } else {// ww w . j av a 2 s . c om return defaultValue; } }