public abstract class XmlUtil
{
public XmlUtil()
{
}
private static String getXPathExpression(Node node, String xPath)
{
StringBuilder sb = new StringBuilder();
sb.append(node.getNodeName()).append("/").append(xPath);
return sb.toString();
}
public static List getChildElementsByTagName(Element ele, String childEleName)
{
NodeList nl = ele.getChildNodes();
List childEles = new ArrayList();
for(int i = 0; i < nl.getLength(); i++)
{
Node node = nl.item(i);
if((node instanceof Element) && nodeNameEquals(node, childEleName))
childEles.add(node);
}
return childEles;
}
public static Element getChildElementByTagName(Element ele, String childEleName)
{
NodeList nl = ele.getChildNodes();
for(int i = 0; i < nl.getLength(); i++)
{
Node node = nl.item(i);
if((node instanceof Element) && nodeNameEquals(node, childEleName))
return (Element)node;
}
return null;
}