Here you can find the source of getListContent(Element listElement, String listItemName, String listItemNamespace)
public static ArrayList<String> getListContent(Element listElement, String listItemName, String listItemNamespace)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import java.util.ArrayList; public class Main { /**//w ww . j a v a 2s. c o m * Get list content for the given XML element, of the form <Element>content</Element>... */ public static ArrayList<String> getListContent(Element listElement, String listItemName, String listItemNamespace) { if (listElement == null) { throw new IllegalArgumentException("listElement cannot be null"); } if (listItemName == null || listItemName.length() == 0) { throw new IllegalArgumentException( "listItemName cannot be null or empty"); } if (listItemNamespace == null) { throw new IllegalArgumentException( "listItemNamespace cannot be null"); } ArrayList<String> listContent = new ArrayList<String>(); for (Node childNode = listElement.getFirstChild(); childNode != null; childNode = childNode .getNextSibling()) { if (childNode.getNodeType() == Node.ELEMENT_NODE && listItemName.equals(childNode.getLocalName()) && listItemNamespace .equals(childNode.getNamespaceURI())) { listContent.add(getContent((Element) childNode)); } } return listContent; } /** * Get the content value for the given XML element */ public static String getContent(Element xmlElement) { if (xmlElement == null) { throw new IllegalArgumentException("xmlElement cannot be null"); } StringBuilder content = new StringBuilder(); for (Node childNode = xmlElement.getFirstChild(); childNode != null; childNode = childNode .getNextSibling()) { if (childNode.getNodeType() == Node.TEXT_NODE) { content.append(childNode.getNodeValue()); } } return content.toString(); } }