Package xml
Class Util
java.lang.Object
xml.Util
public class Util
extends java.lang.Object
A collection of functions to help parse the XML document.
-
Method Summary
Modifier and Type Method Description static org.w3c.dom.ElementgetChild(org.w3c.dom.Element parent, java.lang.String name)Get a the first direct children with a given name of the given XML element.static java.util.List<org.w3c.dom.Element>getChildren(org.w3c.dom.Element parent)Get a list of direct children of the given XML element.static java.util.List<org.w3c.dom.Element>getChildren(org.w3c.dom.Element parent, java.lang.String name)Get a list of direct children with a given name of the given XML element.static booleanhasChild(org.w3c.dom.Element parent, java.lang.String name)Returns whether or not the given XML element has a child of the given name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
hasChild
public static boolean hasChild(org.w3c.dom.Element parent, java.lang.String name)Returns whether or not the given XML element has a child of the given name.- Parameters:
parent- The element whose children to find.name- The name of the element to find.- Returns:
- whether or not the given XML element has a child of the given name.
-
getChild
public static org.w3c.dom.Element getChild(org.w3c.dom.Element parent, java.lang.String name)Get a the first direct children with a given name of the given XML element.- Parameters:
parent- The element whose children to find.name- The name of the element to find.- Returns:
- The list of direct children of the given XML element.
- Throws:
XmlParserException- if the parent does not contain a direct child with the given name.
-
getChildren
public static java.util.List<org.w3c.dom.Element> getChildren(org.w3c.dom.Element parent, java.lang.String name)Get a list of direct children with a given name of the given XML element.- Parameters:
parent- The element whose children to find.name- The name of the elements to find.- Returns:
- The list of direct children with the given name.
-
getChildren
public static java.util.List<org.w3c.dom.Element> getChildren(org.w3c.dom.Element parent)Get a list of direct children of the given XML element.- Parameters:
parent- The element whose children to find.- Returns:
- The list of direct children of the given XML element.
-