List of utility methods to do XML Element Get Value
String | getText(Element element) Concatenates the values of all child nodes of type 'Text' or 'CDATA'/ StringBuilder content = new StringBuilder(); if (element != null) { NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node child = nodes.item(i); if (isText(child)) { content.append(((CharacterData) child).getData()); return (content.length() == 0) ? null : content.toString(); |
String | getText(Element element) Get the text that is associated with this element. String text = null; Node node = element.getFirstChild(); while ((node != null) && (text == null)) { if ((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.CDATA_SECTION_NODE)) { text = ((CharacterData) node).getData(); node = node.getNextSibling(); if (text != null) text = text.trim(); return text; |
String | getText(Element element) Gets the text data enclosed by the specified element. NodeList nodeList = element.getChildNodes(); StringBuilder buf = new StringBuilder(); int numTextNodes = 0; for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.getNodeType() == Node.TEXT_NODE) { if (!((Text) node).isElementContentWhitespace()) { numTextNodes++; ... |
String | getText(Element element) Get the text for an element, which is considered the first Text child element. NodeList nodeList = element.getChildNodes(); if (nodeList.item(0) instanceof Text) { return nodeList.item(0).getTextContent(); return null; |
String | getText(Element element) get Text StringBuilder buf = new StringBuilder(); NodeList list = element.getChildNodes(); boolean found = false; for (int i = 0; i < list.getLength(); i++) { Node node = list.item(i); if (node.getNodeType() == Node.TEXT_NODE) { buf.append(node.getNodeValue()); found = true; ... |
String | getText(Element element, String name) Convenience method to get the first String value with a particular tag name in an XML document element. NodeList node_list = element.getElementsByTagName(name);
NodeList element_list = ((Element) node_list.item(0)).getChildNodes();
return (element_list.item(0)).getNodeValue();
|
String | getText(Element element, String tagName) get Text return element.getElementsByTagName(tagName).item(0).getTextContent();
|
String | getText(Element node) get Text StringBuffer sb = new StringBuffer(); NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node child = list.item(i); switch (child.getNodeType()) { case Node.CDATA_SECTION_NODE: case Node.TEXT_NODE: sb.append(child.getNodeValue()); ... |
String | getText(final Element el) Gets the text information associated with the given DOM element. final NodeList nodes = el.getChildNodes(); final int len = nodes.getLength(); for (int i = 0; i < len; i++) { final Node node = nodes.item(i); if ("#text".equals(node.getNodeName())) return node.getNodeValue(); return null; ... |
String | getText(final Element element) Obtains the text of the specified element. final Node node = element.getFirstChild(); if (node != null && node.getNodeType() == Node.TEXT_NODE) { return node.getNodeValue().trim(); return null; |