aboutsummaryrefslogtreecommitdiff
path: root/common/src/at/gv/egovernment/moa/util/DOMUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/at/gv/egovernment/moa/util/DOMUtils.java')
-rw-r--r--common/src/at/gv/egovernment/moa/util/DOMUtils.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
index 53b1a0e48..52f6554d5 100644
--- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
@@ -41,6 +41,7 @@ import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+
import at.gv.egovernment.moa.logging.Logger;
/**
@@ -832,5 +833,26 @@ public class DOMUtils {
}
return false;
}
+
+ /**
+ * Selects the (first) element from a node list and returns it.
+ *
+ * @param nl The NodeList to get the element from.
+ * @return The (first) element included in the node list or <code>null</code>
+ * if the node list is <code>null</code> or empty or no element is
+ * included in the list.
+ */
+ public static Element getElementFromNodeList (NodeList nl) {
+ if ((nl == null) || (nl.getLength() == 0)) {
+ return null;
+ }
+ for (int i=0; i<nl.getLength(); i++) {
+ Node node = nl.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element)node;
+ }
+ }
+ return null;
+ }
}