Added DomUtils.getChildElements() method. Also refactored ConfigBeanDefinitionParser.parse() to use it.
This commit is contained in:
@@ -22,3 +22,4 @@
|
||||
</ivy:makepom>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.util.Assert;
|
||||
* @author Rob Harrop
|
||||
* @author Costin Leau
|
||||
* @author Arjen Poutsma
|
||||
* @author Luke Taylor
|
||||
* @see org.w3c.dom.Node
|
||||
* @see org.w3c.dom.Element
|
||||
* @since 1.2
|
||||
@@ -117,6 +118,25 @@ public abstract class DomUtils {
|
||||
return (child != null ? getTextValue(child) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all child elements of the given DOM element
|
||||
|
||||
* @param ele the DOM element to analyze
|
||||
* @return a List of child <code>org.w3c.dom.Element</code> instances
|
||||
*/
|
||||
public static List<Element> getChildElements(Element ele) {
|
||||
Assert.notNull(ele, "Element must not be null");
|
||||
NodeList nl = ele.getChildNodes();
|
||||
List<Element> childEles = new ArrayList<Element>();
|
||||
for (int i = 0; i < nl.getLength(); i++) {
|
||||
Node node = nl.item(i);
|
||||
if (node instanceof Element) {
|
||||
childEles.add((Element) node);
|
||||
}
|
||||
}
|
||||
return childEles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the text value from the given DOM element, ignoring XML comments. <p>Appends all CharacterData nodes and
|
||||
* EntityReference nodes into a single String value, excluding Comment nodes.
|
||||
|
||||
Reference in New Issue
Block a user