Example #1
0
 public static List<Element> getChildNodes(Element e, String byName) {
   List<Element> result = new ArrayList<Element>();
   NodeList l = e.getChildNodes();
   for (int i = 0; i < l.getLength(); i++) {
     if (e.equals(l.item(i).getParentNode()) && byName.equals(l.item(i).getNodeName()))
       result.add((Element) l.item(i));
   }
   return result;
 }
Example #2
0
 @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
 private XedCursor findChildElement(
     final Element child, final XedCursor cursorParent, final XedCursor cursorType) {
   final Xed xed = cursorParent.getXed();
   final Element elementParent = cursorParent.getElement();
   final TypeInstance typeInstance = cursorType.getTypeInstance();
   XedCursor cursor = new XedCursor(xed, cursorType, null, null, typeInstance);
   final Collection<Element> children =
       ElementU.getChildren(elementParent, typeInstance.getName());
   int ordinal = -1;
   for (final Element childIt : children) {
     ++ordinal;
     if (childIt.equals(child)) {
       cursor = new XedCursor(xed, cursorType, childIt, ordinal, typeInstance);
       break;
     }
   }
   return cursor;
 }