@Test public void testNullXPaths_fails() { thrown.expect(NullPointerException.class); thrown.expectMessage("xpath"); nodeExtractor.extractNode(null, null); }
public Node extractNode(@Nullable Node parentNode, Iterable<String> xPath) { Preconditions.checkNotNull(xPath, "Null xpath list"); Node node = parentNode; boolean wasMatch = false; Iterator<String> xPathElementsIter = xPath.iterator(); while (xPathElementsIter.hasNext() && node != null) { wasMatch = false; String localName = xPathElementsIter.next(); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); String childName = childNode.getLocalName(); if (childName == null || childName.contains(":")) { childName = childNode.getNodeName(); } if (localName.equals(childName)) { node = childNode; wasMatch = true; break; } } } return wasMatch ? node : null; }
NodeExtractor { public Node extractNode(@Nullable Node parentNode, Iterable<String> xPath) { Preconditions.checkNotNull(xPath, "Null xpath list"); Node node = parentNode; boolean wasMatch = false; Iterator<String> xPathElementsIter = xPath.iterator(); while (xPathElementsIter.hasNext() && node != null) { wasMatch = false; String localName = xPathElementsIter.next(); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); String childName = childNode.getLocalName(); if (childName == null || childName.contains(":")) { childName = childNode.getNodeName(); } if (localName.equals(childName)) { node = childNode; wasMatch = true; break; } } } return wasMatch ? node : null; } }
NodeExtractor { public Node extractNode(@Nullable Node parentNode, Iterable<String> xPath) { Preconditions.checkNotNull(xPath, "Null xpath list"); Node node = parentNode; boolean wasMatch = false; Iterator<String> xPathElementsIter = xPath.iterator(); while (xPathElementsIter.hasNext() && node != null) { wasMatch = false; String localName = xPathElementsIter.next(); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); String childName = childNode.getLocalName(); if (childName == null || childName.contains(":")) { childName = childNode.getNodeName(); } if (localName.equals(childName)) { node = childNode; wasMatch = true; break; } } } return wasMatch ? node : null; }  }
NodeExtractor { public Node extractNode(@Nullable Node parentNode, Iterable<String> xPath) { Preconditions.checkNotNull(xPath, "Null xpath list"); Node node = parentNode; boolean wasMatch = false; Iterator<String> xPathElementsIter = xPath.iterator(); while (xPathElementsIter.hasNext() && node != null) { wasMatch = false; String localName = xPathElementsIter.next(); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); String childName = childNode.getLocalName(); if (childName == null || childName.contains(":")) { childName = childNode.getNodeName(); } if (localName.equals(childName)) { node = childNode; wasMatch = true; break; } } } return wasMatch ? node : null; }  String extractNodeValue(@Nullable Node parentNode, Iterable<String> xPath); Node extractNode(@Nullable Node parentNode, Iterable<String> xPath); }
NodeExtractor { public Node extractNode(@Nullable Node parentNode, Iterable<String> xPath) { Preconditions.checkNotNull(xPath, "Null xpath list"); Node node = parentNode; boolean wasMatch = false; Iterator<String> xPathElementsIter = xPath.iterator(); while (xPathElementsIter.hasNext() && node != null) { wasMatch = false; String localName = xPathElementsIter.next(); NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node childNode = childNodes.item(i); String childName = childNode.getLocalName(); if (childName == null || childName.contains(":")) { childName = childNode.getNodeName(); } if (localName.equals(childName)) { node = childNode; wasMatch = true; break; } } } return wasMatch ? node : null; }  String extractNodeValue(@Nullable Node parentNode, Iterable<String> xPath); Node extractNode(@Nullable Node parentNode, Iterable<String> xPath);  }