@Test public void testNoPrologBasicRead() throws XMLException { Path xmlFile = getExampleXml( "no-prolog-basic.xml" ); XMLReader reader = new XMLReader( "basic", xmlFile ); List<Node> fruits = reader.getElementList( " assertElementTexts( fruits, new String[] { "apple", "cherry", "pear", "peach" } ); }
@SuppressWarnings("unchecked") public List<Node> getElementList( String xpathExpr ) throws XMLException { XPathExpression xpath = null; try { xpath = createXPath( xpathExpr ); Object evaluated = xpath.evaluate( document, XPathConstants.NODESET); if ( evaluated == null ) { return Collections.emptyList(); } NodeList nl = (NodeList) evaluated; List<Node> nodeList = new ArrayList<>(); for (int i = 0 ; i<nl.getLength(); i++) { nodeList.add(nl.item(i)); } return nodeList; } catch (XPathExpressionException e) { throw new XMLException("Could not parse xpath expression"); } }
XMLReader { @SuppressWarnings("unchecked") public List<Node> getElementList( String xpathExpr ) throws XMLException { XPathExpression xpath = null; try { xpath = createXPath( xpathExpr ); Object evaluated = xpath.evaluate( document, XPathConstants.NODESET); if ( evaluated == null ) { return Collections.emptyList(); } NodeList nl = (NodeList) evaluated; List<Node> nodeList = new ArrayList<>(); for (int i = 0 ; i<nl.getLength(); i++) { nodeList.add(nl.item(i)); } return nodeList; } catch (XPathExpressionException e) { throw new XMLException("Could not parse xpath expression"); } } }
XMLReader { @SuppressWarnings("unchecked") public List<Node> getElementList( String xpathExpr ) throws XMLException { XPathExpression xpath = null; try { xpath = createXPath( xpathExpr ); Object evaluated = xpath.evaluate( document, XPathConstants.NODESET); if ( evaluated == null ) { return Collections.emptyList(); } NodeList nl = (NodeList) evaluated; List<Node> nodeList = new ArrayList<>(); for (int i = 0 ; i<nl.getLength(); i++) { nodeList.add(nl.item(i)); } return nodeList; } catch (XPathExpressionException e) { throw new XMLException("Could not parse xpath expression"); } } XMLReader( String type, Path file );  XMLReader( String type, StorageAsset asset);  XMLReader( String type, URL url ); }
XMLReader { @SuppressWarnings("unchecked") public List<Node> getElementList( String xpathExpr ) throws XMLException { XPathExpression xpath = null; try { xpath = createXPath( xpathExpr ); Object evaluated = xpath.evaluate( document, XPathConstants.NODESET); if ( evaluated == null ) { return Collections.emptyList(); } NodeList nl = (NodeList) evaluated; List<Node> nodeList = new ArrayList<>(); for (int i = 0 ; i<nl.getLength(); i++) { nodeList.add(nl.item(i)); } return nodeList; } catch (XPathExpressionException e) { throw new XMLException("Could not parse xpath expression"); } } XMLReader( String type, Path file );  XMLReader( String type, StorageAsset asset);  XMLReader( String type, URL url ); String getDefaultNamespaceURI(); void addNamespaceMapping( String elementName, String uri ); Element getElement( String xpathExpr ); boolean hasElement( String xpathExpr ); void removeNamespaces(); @SuppressWarnings("unchecked") void removeNamespaces( Node elem ); String getElementText( Node context, String xpathExpr ); String getElementText( String xpathExpr ); @SuppressWarnings("unchecked") List<Node> getElementList( String xpathExpr ); List<String> getElementListText( String xpathExpr ); }
XMLReader { @SuppressWarnings("unchecked") public List<Node> getElementList( String xpathExpr ) throws XMLException { XPathExpression xpath = null; try { xpath = createXPath( xpathExpr ); Object evaluated = xpath.evaluate( document, XPathConstants.NODESET); if ( evaluated == null ) { return Collections.emptyList(); } NodeList nl = (NodeList) evaluated; List<Node> nodeList = new ArrayList<>(); for (int i = 0 ; i<nl.getLength(); i++) { nodeList.add(nl.item(i)); } return nodeList; } catch (XPathExpressionException e) { throw new XMLException("Could not parse xpath expression"); } } XMLReader( String type, Path file );  XMLReader( String type, StorageAsset asset);  XMLReader( String type, URL url ); String getDefaultNamespaceURI(); void addNamespaceMapping( String elementName, String uri ); Element getElement( String xpathExpr ); boolean hasElement( String xpathExpr ); void removeNamespaces(); @SuppressWarnings("unchecked") void removeNamespaces( Node elem ); String getElementText( Node context, String xpathExpr ); String getElementText( String xpathExpr ); @SuppressWarnings("unchecked") List<Node> getElementList( String xpathExpr ); List<String> getElementListText( String xpathExpr );  }