List of usage examples for org.w3c.dom Node getTextContent
public String getTextContent() throws DOMException;
From source file:it.pronetics.madstore.crawler.publisher.impl.AtomPublisherImpl.java
private void setUpdatedDateTimeIfNecessary(Element entry) { NodeList updatedNodes = entry.getElementsByTagName(AtomConstants.ATOM_ENTRY_UPDATED); Node updatedNode = updatedNodes.item(0); if (updatedNode != null) { String entryUpdatedDateTime = updatedNode.getTextContent(); if (entryUpdatedDateTime == null || entryUpdatedDateTime.equals("")) { LOG.warn("The entry has no updated date, using current time ..."); updatedNode.setTextContent(ISODateTimeFormat.dateTime().print(System.currentTimeMillis())); }/*w w w . j a v a2 s . c om*/ } else { LOG.warn("The entry has no updated date, using current time ..."); updatedNode = entry.getOwnerDocument().createElementNS(AtomConstants.ATOM_NS, AtomConstants.ATOM_ENTRY_UPDATED); updatedNode.setTextContent(ISODateTimeFormat.dateTime().print(System.currentTimeMillis())); entry.appendChild(updatedNode); } }
From source file:at.ait.dme.yuma.server.map.KMLConverterServlet.java
private Document convert(Document kml, AffineTransformation interpolator) { // Get all 'coordinates' nodes NodeList coordNodes = kml.getElementsByTagName("coordinates"); StringBuffer sb;/*from ww w. j ava 2 s .c o m*/ String[] coords; String[] lonlat; TransformationResult ir; for (int i = 0; i < coordNodes.getLength(); i++) { // Construct result coordinate string sb = new StringBuffer(); // Original WGS84 coordinate set: 'lon,lat,alt lon,lat,alt lon,lat,alt ...' Node n = coordNodes.item(i); // Split into individual WGS84 coordinates: 'lon,lat,alt' coords = n.getTextContent().trim().split(" "); int lastX = 0; int lastY = 0; double dist = 0; for (int j = 0; j < coords.length; j++) { // Split into coordinate values lonlat = coords[j].split(","); if (lonlat.length > 1) { try { // Interpolate ir = interpolator.getXYFromKnownLatLon( new WGS84Coordinate(Double.parseDouble(lonlat[1]), Double.parseDouble(lonlat[0]))); // Threshold check: does the distance between this point and // the last one exceed the threshold? --> Outlier! Don't add dist = Math.sqrt(Math.pow((ir.xy.x - lastX), 2) + Math.pow((ir.xy.y - lastY), 2)); if ((j == 0) || (dist < outlierThreshold)) { sb.append(ir.xy.x + "," + ir.xy.y + "\n"); lastX = ir.xy.x; lastY = ir.xy.y; } } catch (TransformationException e) { // Cannot happen unless interpolator is invalid throw new RuntimeException(e); } } } // Replace node n.setTextContent(sb.toString()); } return kml; }
From source file:gov.nih.nci.cacis.ip.mirthconnect.CanonicalModelProcessorMCIntegrationTest.java
@Test public void invokeSOAP() throws Exception { final Node res = invoke(ADDRESS, SoapTransportFactory.TRANSPORT_ID, getValidMessage().getBytes()); assertNotNull(res);/* w w w.j a v a 2 s. c o m*/ assertValid("//ns2:caCISResponse[@status='SUCCESS']", res); LOG.info("Echo response: " + res.getTextContent()); }
From source file:com.appdynamics.monitors.ehcache.EhcacheRESTWrapper.java
/** * Converts the inputstream retrieved from the connection to Ehcache host into a HashMap of metrics * @param is Inputstream retrieved from the connection to Ehcache host * @return HashMap containing metrics for all the caches registered to this Ehcache host *//*from w w w. java 2 s . c om*/ private HashMap convertResponseToMap(InputStream is) throws Exception { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); dbFactory.setNamespaceAware(true); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(is); NodeList caches = doc.getElementsByTagName(CACHE_NODE); HashMap<String, HashMap<String, Number>> metricsMap = new HashMap<String, HashMap<String, Number>>(); for (int i = 0; i < caches.getLength(); i++) { Node cache = caches.item(i); NodeList cacheNodes = cache.getChildNodes(); String cacheName = null; for (int j = 0; j < cacheNodes.getLength(); j++) { Node cacheNode = cacheNodes.item(j); if (cacheNode.getNodeName().equalsIgnoreCase(CACHE_NODE_NAME)) { cacheName = cacheNode.getTextContent(); metricsMap.put(cacheNode.getTextContent(), new HashMap<String, Number>()); } if (cacheNode.getNodeName().equalsIgnoreCase(CACHE_STATISTICS_NODE)) { NodeList statistics = cacheNode.getChildNodes(); HashMap<String, Number> statisticsMap = new HashMap<String, Number>(); for (int k = 0; k < statistics.getLength(); k++) { Node statisticsNode = statistics.item(k); Number value; if (NumberUtils.isNumber(statisticsNode.getTextContent())) { if (statisticsNode.getTextContent().contains(".")) { value = Double.parseDouble(statisticsNode.getTextContent()); } else { value = Long.parseLong(statisticsNode.getTextContent()); } statisticsMap.put(statisticsNode.getNodeName(), value); } } if (cacheName != null) { metricsMap.put(cacheName, statisticsMap); } } } } return metricsMap; }
From source file:com.panet.imeta.core.xml.XMLHandler.java
/** * Get node child with a certain subtag set to a certain value * /*from w w w. j a v a 2 s . c o m*/ * @param n * The node to search in * @param tag * The tag to look for * @param subtag * The subtag to look for * @param subtagvalue * The value the subtag should have * @param nr * The nr of occurance of the value * @return The node found or null if we couldn't find anything. */ public static final Node getNodeWithAttributeValue(Node n, String tag, String attributeName, String attributeValue) { NodeList children; Node childnode; children = n.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { childnode = children.item(i); if (childnode.getNodeName().equalsIgnoreCase(tag)) // <hop> { Node attribute = childnode.getAttributes().getNamedItem(attributeName); if (attribute != null && attributeValue.equals(attribute.getTextContent())) return childnode; } } return null; }
From source file:prodoc.FTRemote.java
@Override protected ArrayList<String> Search(String Type, String sDocMetadata, String sBody, String sMetadata) throws PDException { if (PDLog.isDebug()) PDLog.Debug("FTRemote.Search:" + Type + "/"); ArrayList<String> Res = new ArrayList<String>(); Node N = ReadWrite(DriverGeneric.S_FTSEARCH, "<OPD><Type>" + Type + "</Type><DocMetadata>" + (sDocMetadata != null ? sDocMetadata : "") + "</DocMetadata><Body>" + sBody + "</Body><Metadata>" + sMetadata + "</Metadata></OPD>"); NodeList RecLst = N.getChildNodes(); for (int i = 0; i < RecLst.getLength(); i++) { Node ID = RecLst.item(i); String IdRes = ""; if (ID.getNodeName().equalsIgnoreCase("ID")) { IdRes = ID.getTextContent(); Res.add(IdRes);//from w w w. j ava 2s .c o m } } return (Res); }
From source file:au.com.ors.soap.crv.CRVPortTypeImpl.java
public String check(String driverLicenseNumber) throws ParserConfigurationException, SAXException, IOException { Document dom;/*from ww w .jav a 2 s . c o m*/ URL path = this.getClass().getClassLoader().getResource("../db/bpeldb.xml"); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db; db = dbf.newDocumentBuilder(); dom = db.parse(path.toString()); Element rootElement = dom.getDocumentElement(); NodeList nodeList = rootElement.getChildNodes(); for (int i = 0; i < nodeList.getLength(); ++i) { Node node = nodeList.item(i); if (!node.getNodeName().equalsIgnoreCase("bpelElement")) { continue; } NodeList attributeList = node.getChildNodes(); for (int j = 0; j < attributeList.getLength(); ++j) { Node currentNode = attributeList.item(j); if (currentNode.getNodeType() == Node.ELEMENT_NODE) { if (currentNode.getNodeName().equalsIgnoreCase("driverLicenseNumber")) { if (!currentNode.getTextContent().equalsIgnoreCase(driverLicenseNumber)) { break; } } else if (currentNode.getNodeName().equalsIgnoreCase("criminalRecord")) { if (!StringUtils.isEmpty(currentNode.getTextContent())) { return HASRECORD; } } } } } return NORECORD; }
From source file:eu.guardiansystems.livesapp.android.ui.GMapDirections.java
public String getEndAddress() { try {/* w w w .ja v a 2 s . c om*/ NodeList nl1 = mDocument.getElementsByTagName("end_address"); Node node1 = nl1.item(0); return node1.getTextContent(); } catch (Exception e) { return "-1"; } }
From source file:eu.guardiansystems.livesapp.android.ui.GMapDirections.java
public String getStartAddress(Document doc) { try {/*from w w w. ja v a 2 s . c o m*/ NodeList nl1 = doc.getElementsByTagName("start_address"); Node node1 = nl1.item(0); return node1.getTextContent(); } catch (Exception e) { return "-1"; } }
From source file:eu.guardiansystems.livesapp.android.ui.GMapDirections.java
public String getCopyRights() { try {//ww w.j a v a 2 s.c om NodeList nl1 = mDocument.getElementsByTagName("copyrights"); Node node1 = nl1.item(0); return node1.getTextContent(); } catch (Exception e) { return "-1"; } }