List of utility methods to do XML Element Value Get
String | getNodeValue(Element node) This will get the text value of an element. String retval = ""; NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node next = children.item(i); if (next instanceof Text) { retval = next.getNodeValue(); return retval; |
String | getNodeValue(Element node) This will get the text value of an element. StringBuilder sb = new StringBuilder(); NodeList children = node.getChildNodes(); int numNodes = children.getLength(); for (int i = 0; i < numNodes; i++) { Node next = children.item(i); if (next instanceof Text) { sb.append(next.getNodeValue()); return sb.toString(); |
String | getText(Element parentNode) Extracts the String content of a TXT element. Text text = getTextNode(parentNode);
return (text == null) ? null : text.getData();
|
Text | getTextNode(Element element) Returns element's TEXT child node (if it has one). return (Text) getChildByType(element, Node.TEXT_NODE);
|
String | getTextTrim(Element elto) get Text Trim StringBuffer content = new StringBuffer(); NodeList contentE = elto.getChildNodes(); int i = 0; while (contentE.item(i) != null && (contentE.item(i).getNodeType() == Node.TEXT_NODE || contentE .item(i).getNodeType() == Node.CDATA_SECTION_NODE)) { content.append(((Text) contentE.item(i)).getNodeValue()); i++; ... |
String | getTextTrim(Element elto) get Text Trim StringBuffer content = new StringBuffer(); NodeList contentE = elto.getChildNodes(); int i = 0; while (contentE.item(i) != null && (contentE.item(i).getNodeType() == Node.TEXT_NODE || contentE .item(i).getNodeType() == Node.CDATA_SECTION_NODE)) { content.append(((Text) contentE.item(i)).getNodeValue()); i++; ... |
String | getValue(Element element) Get the text value for the specified element. if (element != null) { Node dataNode = element.getFirstChild(); if (dataNode != null) { return ((Text) dataNode).getData(); return null; |
String | getValue(Element element, String elementName) get Value NodeList elements = element.getElementsByTagName(elementName); if (1 != elements.getLength()) { throw new IllegalStateException( "TODO: handle when elements does not contain exactly one item.elementName=" + elementName); Node elementNode = elements.item(0); NodeList children = elementNode.getChildNodes(); ... |
String | getValue(Element item, String str) get Value NodeList n = item.getElementsByTagName(str);
return getElementValue(n.item(0));
|
String | getStringValue(String tag, Element element) get String Value NodeList nodes = element.getElementsByTagName(tag).item(0)
.getChildNodes();
Node node = (Node) nodes.item(0);
return node.getNodeValue();
|