From 6551ddb13f38b3d96719f5c21f10da6ff80d5d13 Mon Sep 17 00:00:00 2001 From: "harald.bratko" Date: Fri, 2 Sep 2005 10:13:32 +0000 Subject: Added method for retrieving child elments of an element. git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@476 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../src/at/gv/egovernment/moa/util/DOMUtils.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'common/src/at/gv') diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java index 52f6554d5..fddf16944 100644 --- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java +++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java @@ -7,8 +7,10 @@ import java.io.InputStream; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; +import java.util.Vector; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -854,5 +856,26 @@ public class DOMUtils { } return null; } + + /** + * Returns all child elements of the given element. + * + * @param parent The element to get the child elements from. + * + * @return A list including all child elements of the given element. + * Maybe empty if the parent element has no child elements. + */ + public static List getChildElements (Element parent) { + Vector v = new Vector(); + NodeList nl = parent.getChildNodes(); + int length = nl.getLength(); + for (int i=0; i < length; i++) { + Node node = nl.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + v.add((Element)node); + } + } + return v; + } } -- cgit v1.2.3