List of utility methods to do XML Node Value Get
String | getText(Node node, String tag) get Text Node n = getChild(node, tag); if (n != null) { Node text = n.getFirstChild(); if (text != null) { String s = text.getNodeValue(); return s.trim(); return ""; |
String | getText(Node node, String tag) get Text Node child = getChild(node, tag); if (child != null) { Node text = child.getFirstChild(); if (text != null && !"".equals(text)) { String value = text.getNodeValue(); return value.trim(); return null; |
String | getText(Node node, String tag) get Text Node n = getChild(node, tag); if (n != null) { Node text = n.getFirstChild(); if (text != null) { String s = text.getNodeValue(); return s.trim(); return ""; |
String | getTextContent(Node n) get Text Content StringBuffer buffer = new StringBuffer(); NodeList childList = n.getChildNodes(); Node child; short nodetype; for (int i = 0; i < childList.getLength(); i++) { child = childList.item(i); nodetype = child.getNodeType(); if (nodetype != Node.TEXT_NODE ... |
String | getTextContent(Node n) get Text Content Node child = n.getFirstChild(); if (child != null) { Node next = child.getNextSibling(); if (next == null) { return hasTextContent(child) ? child.getNodeValue() : ""; StringBuffer buf = new StringBuffer(); getTextContent(n, buf); ... |
void | getTextContent(Node n, StringBuffer buf) get Text Content Node child = n.getFirstChild(); while (child != null) { if (hasTextContent(child)) { String content = child.getNodeValue(); if (content != null) { buf.append(content); child = child.getNextSibling(); |
String | getTextContent(org.w3c.dom.Node element) return the text content of an element StringBuffer childtext = new StringBuffer(); NodeList childlist = element.getChildNodes(); int ct = childlist.getLength(); for (int j = 0; j < ct; j++) { org.w3c.dom.Node childNode = childlist.item(j); if ((childNode.getNodeType() == Node.TEXT_NODE) || (childNode.getNodeType() == Node.CDATA_SECTION_NODE)) { childtext.append(childNode.getNodeValue().trim()); ... |
String | getTextNodeValue(Node node) get Text Node Value Node child; if (node != null) { if (node.hasChildNodes()) { child = node.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.TEXT_NODE) { return child.getNodeValue(); child = child.getNextSibling(); return ""; |
String | getXml(Node node) get Xml StringBuilder buffer = new StringBuilder(); if (node == null) { return ""; if (node instanceof Document) { buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); buffer.append(getXml(((Document) node).getDocumentElement())); } else if (node instanceof Element) { ... |
int | getXmlInt(Node node, String xmlLocalName, int defaultValue) Retrieves the value of that XML element as an integer. String s = getXmlString(node, xmlLocalName); try { return Integer.parseInt(s); } catch (NumberFormatException e) { return defaultValue; |