Finds child elements in DOM.
@param parent The Element to find in
@param tagName The element to find
@return List of elements
555110
protected static List<Element> getElements(final Element parent, final String tagName) {
        List<Element> elements = new ArrayList<Element>();
        NodeList nodes = parent.getElementsByTagName(tagName);
        for (int i = 0; i < nodes.getLength(); i++) {
            org.w3c.dom.Node node = nodes.item(i);
            if (node instanceof Element) {
                elements.add(Element.class.cast(node));
            }
        }
        return elements;
    }
82219
public List<Element> findElements(String tag) {
    List<Element> result = new ArrayList<>();
    LinkedList<Element> stack = new LinkedList<>(this.getChildren());

    if (tag.equalsIgnoreCase(this.getMessageMLTag())) {
      result.add(this);
    }

    while (!stack.isEmpty()) {
      Element child = stack.pop();
      stack.addAll(0, child.getChildren());
      if (tag.equalsIgnoreCase(child.getMessageMLTag())) {
        result.add(child);
      }
    }

    return result;
  }
105286
public function getElementByTagName($tagName)
    {
        if (null === $this->treeRoot){
            return array();
        }
        $children = $this->treeRoot->getChildren();

        return $this->getElementByTagInChildren($children, $tagName);
    }
685822
Tag[] tags(String tagname) {
        ListBuffer<Tag> found = new ListBuffer<Tag>();
        String target = tagname;
        if (target.charAt(0) != '@') {
            target = "@" + target;
        }
        for (Tag tag : tagList) {
            if (tag.kind().equals(target)) {
                found.append(tag);
            }
        }
        return found.toArray(new Tag[found.length()]);
    }
878397
@SuppressWarnings("unchecked")
    private <T extends DomElement> List<T> allByTagName(String tagName) {
        return (List<T>) htmlPage.getElementsByTagName(tagName);
    }
473503
public static List<Element> getElementsByClass(String className, Element rootElement) {

        return getElementsByClass(className, Tag.ALL, rootElement);

    }
811318
private String getElementValue(Element parent, String elementName) {
        String value = null;
        NodeList nodes = parent.getElementsByTagName(elementName);
        if (nodes.getLength() > 0) {
            value = nodes.item(0).getChildNodes().item(0).getNodeValue();
        }
        return value;
    }
137509
public XMLElement[] getChildren(String name) {

        java.util.List<XMLElement> list = new java.util.ArrayList<XMLElement>();

        for (XMLElement child : getChildren()) {
            if (child.getName().equals(name)) {
                list.add(child);
            }
        }

        return (0 < list.size()) ? list.toArray(new XMLElement[0]) : null;
    }
1216204
def getElements(self,name=''):
		''
		#If no tag name is specified, return the all children
		if not name:
			return self.children
		else:
			# else return only those children with a matching tag name
			elements = []
			for element in self.children:
				if element.name == name:
					elements.append(element)
			return elements
320382
public static Collection<Node> findElementsByName(String elementName, Node node)
	{
		if ( node == null ||
			node.getNodeType() == Node.COMMENT_NODE ||
			node.getNodeType() == Node.TEXT_NODE )
			return null;

		HashSet<Node> results = new HashSet<Node>();

		if (elementName.equals(node.getNodeName()))
		{
			results.add(node);
		}

		NodeList nodeList = node.getChildNodes();

		if (nodeList == null)
			return null;

		int len = nodeList.getLength();

		Node child;

		for (int i = 0; i < len; i++)
		{
			child = nodeList.item(i);

			if (child.getNodeType() == Node.TEXT_NODE)
				continue;

			if (elementName.equals(child.getNodeName()))
				 results.add(child);

			// check for next
			NodeList grands = child.getChildNodes();
			if (grands != null)
			{
				int grandsCnt = grands.getLength();
				for (int x = 0; x < grandsCnt; x++)
				{
					Collection<Node> grandResults = findElementsByName(elementName, grands.item(x));

					if (grandResults != null)
						results.addAll(grandResults);
				}
			}
		}

		return results.isEmpty()? null : results;

	}
1030765
public static List<Element> getChildren(Element parent, String childName) {
		ArrayList<Element> children = new ArrayList<Element>();
		NodeList nodes = parent.getChildNodes();
		for (int i = 0; i < nodes.getLength(); ++i) {
			Node node = nodes.item(i);
			if ((node instanceof Element) && node.getNodeName().equals(childName))
				children.add((Element)node);
		}
		return children;
	}
800015
function getNodes(tags, context) {
  var keys = objectKeys(tags);
  var returns = [];

  // keys to uppercase to compare to nodeName
  for(var i=0; i<keys.length; i++) keys[i]=keys[i].toUpperCase();

  // if context is tag
  if(keys.indexOf(context.nodeName.toUpperCase()) >= 0) {
    return [context];
  };

  //Mount all top-level child tags within context
  var nodes, el, mount, n;
  for(var i=0; i<keys.length; i++) {
    nodes = context.getElementsByTagName(keys[i]);
    for(n=0; n<nodes.length; n++) {
      el = nodes[n];
      mount = true;
      while(el = el.parentNode) {
        if(keys.indexOf(el.nodeName.toUpperCase()) >= 0) {
          mount = false;
          break;
        }
        if(el === context) break;
      }
      if(mount) returns.push(nodes[n]);
    }
  }  
  return returns;
}
696045
static Element getChildByName(Node parent, String nodeName) {
	return getChildByName(parent, nodeName, false);
    }
523793
def _find(self, root, tagname, id=None):
        """"""
        if id is None:
            result = root.find('.//%s' % tagname)
            if result is None:
                raise LookupError('Cannot find any %s elements' % tagname)
            else:
                return result
        else:
            result = [
                elem for elem in root.findall('.//%s' % tagname)
                if elem.attrib.get('id', '') == id
            ]
            if len(result) == 0:
                raise LookupError('Cannot find a %s element with id %s' % (tagname, id))
            elif len(result) > 1:
                raise LookupError('Found multiple %s elements with id %s' % (tagname, id))
            else:
                return result[0]
48731
public static Element getChild(Element element, String name) {
        return (Element) element.getElementsByTagName(name).item(0);
    }
1244740
def getElementsByTagName(start_node: ParentNode, tag: str) -> NodeList:
    """"""
    _tag = tag.upper()
    return getElementsBy(start_node, lambda node: node.tagName == _tag)
458570
public ExcludeByParentBuilder dontClickChildrenOf(String tagName) {
		checkNotRead();
		Preconditions.checkNotNull(tagName);
		ExcludeByParentBuilder exclude = new ExcludeByParentBuilder(
				tagName.toUpperCase());
		crawlParentsExcluded.add(exclude);
		return exclude;
	}