1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springmodules.validation.util.xml;
18
19 import java.util.Iterator;
20
21 import org.w3c.dom.Element;
22 import org.w3c.dom.Node;
23 import org.w3c.dom.NodeList;
24
25
26
27
28
29
30 public class DomUtils {
31
32 public static Element firstChildElement(Element element) {
33 Iterator iter = childElements(element);
34 return (iter.hasNext()) ? (Element) iter.next() : null;
35 }
36
37 public static Iterator childElements(Element element) {
38 return new SubElementsIterator(element);
39 }
40
41 public static Iterator childNodes(Node node) {
42 return new ChildNodesIterator(node);
43 }
44
45 public static Element getSingleSubElement(Element parent, String elementNamespace, String localName) {
46 NodeList nodes = parent.getElementsByTagNameNS(elementNamespace, localName);
47 return (nodes.getLength() > 0) ? (Element) nodes.item(0) : null;
48 }
49
50
51 private DomUtils() {
52 }
53
54 }
55