private static XmlElement findFpmlRoot(XmlElement root) { XmlElement fpmlRoot = getFpmlRoot(root); if (fpmlRoot != null) { return fpmlRoot; } // try children of root element for (XmlElement el : root.getChildren()) { fpmlRoot = getFpmlRoot(el); if (fpmlRoot != null) { return fpmlRoot; } } // try grandchildren of root element for (XmlElement el1 : root.getChildren()) { for (XmlElement el2 : el1.getChildren()) { fpmlRoot = getFpmlRoot(el2); if (fpmlRoot != null) { return fpmlRoot; } } } throw new FpmlParseException("Unable to find FpML root element"); }