/** * Creates a new XMLStructuredInput for the given stream. * * @param in the InputStream containing the xml data. * @param close determines whether the stream should be closed after parsing or not * @throws IOException if an io error occurs while parsing the input xml */ public XMLStructuredInput(InputStream in, boolean close) throws IOException { try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(in); node = StructuredNode.of(doc.getDocumentElement()); if (close) { in.close(); } } catch (ParserConfigurationException | SAXException e) { throw new IOException(e); } }
private boolean nodeUp() { if (isComplete()) { nodeHandler.process(StructuredNode.of(root)); return true; } currentNode = currentNode.getParentNode(); return false; }