@Test public void testGetNodeList() throws DocumentManipulatorException, URISyntaxException, XPathException { URL url = this.getClass().getResource("/sample.xml"); String expression = " Document doc = handler.parseDocument(new File(url.toURI())); NodeList list = handler.getNodeList(doc, expression); assertNotNull("list shoud not be null", list); }
public NodeList getNodeList(Document doc, String expression) throws XPathException { XPath xpath = xPathFactory.newXPath(); xpath.setNamespaceContext(new DocumentNamespaceResolver(doc)); XPathExpression exp = xpath.compile(expression); Object result = exp.evaluate(doc, XPathConstants.NODESET); return (NodeList) result; }
DocumentManipulator { public NodeList getNodeList(Document doc, String expression) throws XPathException { XPath xpath = xPathFactory.newXPath(); xpath.setNamespaceContext(new DocumentNamespaceResolver(doc)); XPathExpression exp = xpath.compile(expression); Object result = exp.evaluate(doc, XPathConstants.NODESET); return (NodeList) result; } }
DocumentManipulator { public NodeList getNodeList(Document doc, String expression) throws XPathException { XPath xpath = xPathFactory.newXPath(); xpath.setNamespaceContext(new DocumentNamespaceResolver(doc)); XPathExpression exp = xpath.compile(expression); Object result = exp.evaluate(doc, XPathConstants.NODESET); return (NodeList) result; } DocumentManipulator(); }
DocumentManipulator { public NodeList getNodeList(Document doc, String expression) throws XPathException { XPath xpath = xPathFactory.newXPath(); xpath.setNamespaceContext(new DocumentNamespaceResolver(doc)); XPathExpression exp = xpath.compile(expression); Object result = exp.evaluate(doc, XPathConstants.NODESET); return (NodeList) result; } DocumentManipulator(); NodeList getNodeList(Document doc, String expression); void serializeDocumentToHtml(Document document, File outputFile, File xslFile); void serializeDocumentToXml(Document document, File outputFile); String serializeDocumentToString(Document document); }
DocumentManipulator { public NodeList getNodeList(Document doc, String expression) throws XPathException { XPath xpath = xPathFactory.newXPath(); xpath.setNamespaceContext(new DocumentNamespaceResolver(doc)); XPathExpression exp = xpath.compile(expression); Object result = exp.evaluate(doc, XPathConstants.NODESET); return (NodeList) result; } DocumentManipulator(); NodeList getNodeList(Document doc, String expression); void serializeDocumentToHtml(Document document, File outputFile, File xslFile); void serializeDocumentToXml(Document document, File outputFile); String serializeDocumentToString(Document document);  }