@Test public void testGetOrCreateChildNode_Missing() throws Exception { Node sampleNode = getSampleNode(); Assert.assertNotNull(xmlUtils.getOrCreateChildNode(SUBNODE_NAME + "invalid", sampleNode)); }
@Override public Node getOrCreateChildNode(String tagName, Node parentNode) { try { Node childNode = (Node)xPath.evaluate("./" + tagName, parentNode, XPathConstants.NODE); if(childNode != null) { return childNode; } Element element = parentNode.getOwnerDocument().createElement(tagName); parentNode.appendChild(element); return element; } catch(Exception e) { return null; } }
XmlUtilsImpl implements XmlUtils { @Override public Node getOrCreateChildNode(String tagName, Node parentNode) { try { Node childNode = (Node)xPath.evaluate("./" + tagName, parentNode, XPathConstants.NODE); if(childNode != null) { return childNode; } Element element = parentNode.getOwnerDocument().createElement(tagName); parentNode.appendChild(element); return element; } catch(Exception e) { return null; } } }
XmlUtilsImpl implements XmlUtils { @Override public Node getOrCreateChildNode(String tagName, Node parentNode) { try { Node childNode = (Node)xPath.evaluate("./" + tagName, parentNode, XPathConstants.NODE); if(childNode != null) { return childNode; } Element element = parentNode.getOwnerDocument().createElement(tagName); parentNode.appendChild(element); return element; } catch(Exception e) { return null; } }  }
XmlUtilsImpl implements XmlUtils { @Override public Node getOrCreateChildNode(String tagName, Node parentNode) { try { Node childNode = (Node)xPath.evaluate("./" + tagName, parentNode, XPathConstants.NODE); if(childNode != null) { return childNode; } Element element = parentNode.getOwnerDocument().createElement(tagName); parentNode.appendChild(element); return element; } catch(Exception e) { return null; } }  @Override String getDocumentXmlString(Document document); @Override Document createDocument(String rootElementName); @Override Document getDocumentFromString(String inputXml); @Override Node getOrCreateChildNode(String tagName, Node parentNode); @Override String getSubNodeText(Node parentNode, String subNodeName, boolean allowNone); @Override String getPathNodeText(Node parentNode, String path, boolean allowNone); @Override void setSubNodeText(Node filterNode, String subNodeName, String newValue); @Override String getAttributeText(Node node, String attribute); @Override Node appendChildNode(Node parentNode, String nodeName, String nodeValue); @Override String getNodeXmlString(Node node); @Override XPath getxPath(); XmlUtilsImpl setxPath(XPath xPath); }
XmlUtilsImpl implements XmlUtils { @Override public Node getOrCreateChildNode(String tagName, Node parentNode) { try { Node childNode = (Node)xPath.evaluate("./" + tagName, parentNode, XPathConstants.NODE); if(childNode != null) { return childNode; } Element element = parentNode.getOwnerDocument().createElement(tagName); parentNode.appendChild(element); return element; } catch(Exception e) { return null; } }  @Override String getDocumentXmlString(Document document); @Override Document createDocument(String rootElementName); @Override Document getDocumentFromString(String inputXml); @Override Node getOrCreateChildNode(String tagName, Node parentNode); @Override String getSubNodeText(Node parentNode, String subNodeName, boolean allowNone); @Override String getPathNodeText(Node parentNode, String path, boolean allowNone); @Override void setSubNodeText(Node filterNode, String subNodeName, String newValue); @Override String getAttributeText(Node node, String attribute); @Override Node appendChildNode(Node parentNode, String nodeName, String nodeValue); @Override String getNodeXmlString(Node node); @Override XPath getxPath(); XmlUtilsImpl setxPath(XPath xPath);  }