XML DOM解析常用方法
1. 根据标签(Tag)名获取元素(Elements)
public static Element[] getElementsByTagNameNR(Element e, String tagName) { Vector<Element> elements = new Vector<Element>(); Node child = e.getFirstChild(); while (child != null) { if (child instanceof Element && child.getNodeName().equals(tagName)) { elements.add((Element) child); } child = child.getNextSibling();
}
Element[] result = new Element[elements.size()]; elements.copyInto(result);
return result; }