List of usage examples for org.w3c.dom Node getTextContent
public String getTextContent() throws DOMException;
From source file:de.ingrid.iplug.opensearch.converter.IngridRSSConverter.java
/** * Get the link of the entry.//from w w w .j av a2 s. c om * * @param item * @return * @throws XPathExpressionException */ private Object getLink(Node item) throws XPathExpressionException { XPath xpath = XPathFactory.newInstance().newXPath(); Node node = (Node) xpath.evaluate("link", item, XPathConstants.NODE); if (node != null) { return node.getTextContent(); } else { return ""; } }
From source file:de.ingrid.iplug.opensearch.converter.IngridRSSConverter.java
/** * Get the title of the entry.//ww w .ja v a 2s. c o m * * @param item * @return * @throws XPathExpressionException */ private Object getTitle(Node item) throws XPathExpressionException { XPath xpath = XPathFactory.newInstance().newXPath(); Node node = (Node) xpath.evaluate("title", item, XPathConstants.NODE); if (node != null) { return node.getTextContent(); } else { return ""; } }
From source file:com.cloud.test.stress.StressTestDirectAttach.java
private static List<String> getSourceNatIPs(InputStream is) { List<String> returnValues = new ArrayList<String>(); try {/*from w w w .j a v a 2 s .c o m*/ DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.parse(is); Element rootElement = doc.getDocumentElement(); NodeList allocatedIpAddrNodes = rootElement.getElementsByTagName("publicipaddress"); for (int i = 0; i < allocatedIpAddrNodes.getLength(); i++) { Node allocatedIpAddrNode = allocatedIpAddrNodes.item(i); NodeList childNodes = allocatedIpAddrNode.getChildNodes(); String ipAddress = null; boolean isSourceNat = false; // assume it's *not* source nat until we find otherwise for (int j = 0; j < childNodes.getLength(); j++) { Node n = childNodes.item(j); if ("ipaddress".equals(n.getNodeName())) { ipAddress = n.getTextContent(); } else if ("issourcenat".equals(n.getNodeName())) { isSourceNat = Boolean.parseBoolean(n.getTextContent()); } } if ((ipAddress != null) && isSourceNat) { returnValues.add(ipAddress); } } } catch (Exception ex) { s_logger.error(ex); } return returnValues; }
From source file:me.willowcheng.makerthings.model.OpenHABWidgetDataSource.java
public void setSourceNode(Node rootNode) { Log.i(TAG, "Loading new data"); if (rootNode == null) return;/*from www . j a va 2s . c om*/ rootWidget = new OpenHABWidget(); rootWidget.setType("root"); if (rootNode.hasChildNodes()) { NodeList childNodes = rootNode.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); if (childNode.getNodeName().equals("widget")) { new OpenHABWidget(rootWidget, childNode); } else if (childNode.getNodeName().equals("title")) { this.setTitle(childNode.getTextContent()); } else if (childNode.getNodeName().equals("id")) { this.setId(childNode.getTextContent()); } else if (childNode.getNodeName().equals("icon")) { this.setIcon(childNode.getTextContent()); } else if (childNode.getNodeName().equals("link")) { this.setLink(childNode.getTextContent()); } } } }
From source file:gov.nij.bundles.intermediaries.ers.EntityResolutionServiceIntermediaryTest.java
private boolean compareTextNodeLists(int personNodeCount, List<Node> nodeList1, List<Node> nodeList2, List<Node> nodeList3, int factor1, int factor2, int factor3) { boolean sorted = true; String priorNode1 = nodeList1.get(0).getTextContent(); String priorNode2 = nodeList2.get(0).getTextContent(); String priorNode3 = nodeList3.get(0).getTextContent(); for (int i = 1; sorted && i < personNodeCount; i++) { Node node1 = nodeList1.get(i); String node1S = node1 == null ? null : node1.getTextContent(); Node node2 = nodeList2.get(i); String node2S = node2 == null ? null : node2.getTextContent(); Node node3 = nodeList3.get(i); String node3S = node3 == null ? null : node3.getTextContent(); int node1Compare = compareWithNull(priorNode1, node1S) * factor1; priorNode1 = node1S;//from w w w . j a va 2s .c o m if (node1Compare > 0) { sorted = false; //log.info("Sort fails on last name compare " + priorNode1 + " " + node1S); } else if (node1Compare == 0) { int node2Compare = compareWithNull(priorNode2, node2S) * factor2; priorNode2 = node2S; if (node2Compare > 0) { sorted = false; //log.info("Sort fails on first name compare " + priorNode2 + " " + node2S); } else if (node2Compare == 0) { int node3Compare = compareWithNull(priorNode3, node3S) * factor3; priorNode3 = node3S; if (node3Compare > 0) { sorted = false; //log.info("Sort fails on id compare " + priorNode3 + " " + node3S); } } } } return sorted; }
From source file:com.cloud.test.stress.StressTestDirectAttach.java
private static List<String> getNonSourceNatIPs(InputStream is) { List<String> returnValues = new ArrayList<String>(); try {/* www.java 2 s . c o m*/ DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.parse(is); Element rootElement = doc.getDocumentElement(); NodeList allocatedIpAddrNodes = rootElement.getElementsByTagName("publicipaddress"); for (int i = 0; i < allocatedIpAddrNodes.getLength(); i++) { Node allocatedIpAddrNode = allocatedIpAddrNodes.item(i); NodeList childNodes = allocatedIpAddrNode.getChildNodes(); String ipAddress = null; boolean isSourceNat = true; // assume it's source nat until we // find otherwise for (int j = 0; j < childNodes.getLength(); j++) { Node n = childNodes.item(j); if ("ipaddress".equals(n.getNodeName())) { ipAddress = n.getTextContent(); } else if ("issourcenat".equals(n.getNodeName())) { isSourceNat = Boolean.parseBoolean(n.getTextContent()); } } if ((ipAddress != null) && !isSourceNat) { returnValues.add(ipAddress); } } } catch (Exception ex) { s_logger.error(ex); } return returnValues; }
From source file:de.ingrid.iplug.opensearch.converter.IngridRSSConverter.java
/** * Get the description of the entry./* w w w . ja va 2 s . c o m*/ * * @param item * @return * @throws XPathExpressionException */ private Object getAbstract(Node item) throws XPathExpressionException { XPath xpath = XPathFactory.newInstance().newXPath(); Node node = (Node) xpath.evaluate("description", item, XPathConstants.NODE); if (node != null) { return node.getTextContent(); } else { return ""; } }
From source file:app.akexorcist.gdaplibrary.GooglePlaceSearch.java
private ContentValues getReferenceData(ContentValues cv, Document doc) { NodeList nl1 = doc.getElementsByTagName("result"); nl1 = nl1.item(0).getChildNodes();/*from www. j a v a 2 s . co m*/ Node node = nl1.item(getNodeIndex(nl1, "name")); cv.put(PLACE_NAME, node.getTextContent()); try { node = nl1.item(getNodeIndex(nl1, "formatted_phone_number")); cv.put(PLACE_PHONENUMBER, node.getTextContent()); } catch (ArrayIndexOutOfBoundsException e) { cv.put(PLACE_PHONENUMBER, "Unknown"); } node = nl1.item(getNodeIndex(nl1, "formatted_address")); cv.put(PLACE_ADDRESS, node.getTextContent()); node = nl1.item(getNodeIndex(nl1, "geometry")); NodeList nl2 = node.getChildNodes(); node = nl2.item(getNodeIndex(nl2, "location")); nl2 = node.getChildNodes(); node = nl2.item(getNodeIndex(nl2, "lat")); cv.put(PLACE_LATITUDE, node.getTextContent()); node = nl2.item(getNodeIndex(nl2, "lng")); cv.put(PLACE_LONGITUDE, node.getTextContent()); node = nl1.item(getNodeIndex(nl1, "icon")); cv.put(PLACE_ICON, node.getTextContent()); return cv; }
From source file:hydrograph.ui.common.util.XMLUtil.java
private void addDataTypeToGridRow(Node node, XPathGridRow xPathGridRow) { String nodeValue = node.getTextContent(); xPathGridRow.setDataTypeValue(getDataTypeOntheBasisOfValue(nodeValue)); xPathGridRow.setDataType(SchemaFieldUtil.INSTANCE.getDataTypeByValue(xPathGridRow.getDataTypeValue())); }
From source file:edu.cornell.mannlib.vitro.utilities.containerneutral.CheckContainerNeutrality.java
private void checkServletNames() { Set<String> servletNames = new HashSet<String>(); for (Node n : findNodes("//j2ee:servlet/j2ee:servlet-name")) { servletNames.add(n.getTextContent()); }/* w ww . j ava2s .c o m*/ Set<String> servletMappingNames = new HashSet<String>(); for (Node n : findNodes("//j2ee:servlet-mapping/j2ee:servlet-name")) { servletMappingNames.add(n.getTextContent()); } servletMappingNames.removeAll(servletNames); for (String name : servletMappingNames) { messages.add("There is a <servlet-mapping> tag for <servlet-name>" + name + "</servlet-name>, but there is " + "no matching <servlet> tag."); } }