private Element grabMathElement ( Element formulaNode ) throws XPathExpressionException , MathConverterException { Element mathEle = Optional . ofNullable ( ( Element ) XMLHelper . getElementB ( formulaNode , xPath . compile ( "./*[1]" ) ) ) . orElseThrow ( ( ) -> new MathConverterException ( "no math element found" ) ) ; // check for the "math" root element if ( mathEle . getNodeName ( ) . toLowerCase ( ) . contains ( "math" ) ) { // no math element present return mathEle ; } throw new MathConverterException ( "no math element found" ) ; }
Tries to get the math element which should be next child following the formula node .