public XmlTool find()

in velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/XmlTool.java [578:614]


    public XmlTool find(String xpath)
    {
        if (xpath == null || xpath.length() == 0 || isEmpty())
        {
            return null;
        }
        if (xpath.indexOf('/') < 0)
        {
            xpath = "//"+xpath;
        }
        List<Node> found = new ArrayList<Node>();
        for (Node n : nodes)
        {
            NodeList lst;
            try
            {
                lst = XmlUtils.search(xpath, n);
            }
            catch(XPathExpressionException xpee)
            {
                getLog().error("could not parse XML expression '{}'", xpath, xpee);
                return null;
            }
            if (lst != null)
            {
                for (int i = 0; i < lst.getLength(); ++i)
                {
                    found.add(lst.item(i));
                }
            }
        }
        if (found.isEmpty())
        {
            return null;
        }
        return new XmlTool(found);
    }