Here you can find the source of getElementsByTagName(Element aElement, String aTagName)
Parameter | Description |
---|---|
aNode | a parameter |
aTagName | a parameter |
public static List<Element> getElementsByTagName(Element aElement, String aTagName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011 www.isandlatech.com (www.isandlatech.com) * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w w w . j ava 2 s . c o m*/ * ogattaz (isandlaTech) - initial API and implementation *******************************************************************************/ import java.util.ArrayList; import java.util.List; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { private Document pDom = null; /** * @param aNode * @param aTagName * @return */ public static List<Element> getElementsByTagName(Element aElement, String aTagName) { if (aElement == null) { return null; } List<Element> wElmts = new ArrayList<Element>(); NodeList wList = aElement.getElementsByTagName(aTagName); for (int wI = 0; wI < wList.getLength(); wI++) { if (wList.item(wI).getNodeType() == Node.ELEMENT_NODE) { wElmts.add((Element) wList.item(wI)); } } return wElmts; } /** * @param aTagName * @return */ public List<Element> getElementsByTagName(String aTagName) { return getElementsByTagName(this.getRootElmt(), aTagName); } /** * @return */ public Element getRootElmt() { return getDom().getDocumentElement(); } /** * @return */ public Document getDom() { return pDom; } }