List of usage examples for org.w3c.dom Node getTextContent
public String getTextContent() throws DOMException;
From source file:Main.java
public static boolean getBoolean(Node node) { return Boolean.parseBoolean(node.getTextContent()); }
From source file:Main.java
public static String getNodeText(Node node) { try {//from ww w . j a va 2s . c o m return node.getTextContent(); } catch (DOMException ex) { return null; } }
From source file:Main.java
public static byte[] tranformTextNodeToByteArray(Node node) { String text = node.getTextContent(); if (text != null) { try {/*from www. j a v a2 s. co m*/ return text.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { // should not happen throw new IllegalStateException(e); } } else { return null; } }
From source file:Main.java
public final static String getTextContent(final Node xmlNode) { return xmlNode == null ? null : xmlNode.getTextContent(); }
From source file:Main.java
public static boolean containsElementByValue(NodeList elements, String value) { for (int i = 0; i < elements.getLength(); i++) { Node node = elements.item(i); if (node.getTextContent().equals(value)) { return true; }/*w ww. j a v a 2s . co m*/ } return false; }
From source file:Main.java
/** * Gets the attribute as a string.// w w w . jav a 2 s .c om * @param key the name of the attribute. * @param map the named node map with the attribute key/value pairs. * @return the attribute value or an empty string if it does not exist. */ public static String getAttribute(String key, NamedNodeMap map) { Node attr = map.getNamedItem(key); return attr != null ? attr.getTextContent() : ""; }
From source file:Main.java
public static String getValue(Element e, String tagName) { try {/*from w ww.j a v a 2 s.com*/ // get node lists of a tag name from a Element NodeList elements = e.getElementsByTagName(tagName); if (elements.getLength() == 0) { return null; } Node node = elements.item(0); return node.getTextContent(); } catch (Exception ex) { ex.printStackTrace(); } return null; }
From source file:Main.java
public static String getNodeProperty(Node node, String key) { NamedNodeMap attributes = node.getAttributes(); Node item = attributes.getNamedItem(key); return item == null ? null : item.getTextContent(); }
From source file:Main.java
/** * Finds the attribute value with the given name * @param node the node/* ww w . ja va 2 s . c o m*/ * @param name the attribute name * @return the attribute value */ public static String findAttribute(Node node, String name) { Node attr = node.getAttributes().getNamedItem(name); return attr.getTextContent(); }
From source file:Main.java
public static String[] getElementsByTagNameArray(String sTag, Element eElement) { String[] array = new String[0]; NodeList nlList = eElement.getElementsByTagName(sTag); if (nlList != null && nlList.item(0) != null) { NodeList nodes = nlList.item(0).getChildNodes(); array = new String[nodes.getLength()]; for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); array[i] = node.getTextContent(); }/*from w w w.ja v a2 s. co m*/ } return array; }