public static List<Element> getDirectChildren(Element parent, String namespace, String tag) {
      List<Element> directChildren = new ArrayList<>();
      NodeList children = parent.getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
         Node child = children.item(i);
         if (child.getNodeType() == Node.ELEMENT_NODE && namespace.equals(child.getNamespaceURI())
               && tag.equals(child.getLocalName())) {
            directChildren.add((Element) child);
         }
      }
      return directChildren;
   }
@Test
   void getDirectChildren() {
      List<Element> children = XmlUtil.getDirectChildren(parent, "http://example.com", "child");
      assertEquals(2, children.size());
      assertEquals("child", children.get(0).getLocalName());
      assertEquals("child", children.get(1).getLocalName());
   }