Here you can find the source of getElement(Document doc, String tagName, int index)
Parameter | Description |
---|---|
doc | XML docuemnt |
tagName | a tag name |
index | a index |
public static Element getElement(Document doc, String tagName, int index)
//package com.java2s; /******************************************************************** * Copyright (c) 1999 The Bean Factory, LLC. * All Rights Reserved.//from w w w . j a v a 2 s . c o m * * The Bean Factory, LLC. makes no representations or * warranties about the suitability of the software, either express * or implied, including but not limited to the implied warranties of * merchantableness, fitness for a particular purpose, or * non-infringement. The Bean Factory, LLC. shall not be * liable for any damages suffered by licensee as a result of using, * modifying or distributing this software or its derivatives. * *******************************************************************/ import org.w3c.dom.*; public class Main { /** Return an Element given an XML document, tag name, and index @param doc XML docuemnt @param tagName a tag name @param index a index @return an Element */ public static Element getElement(Document doc, String tagName, int index) { //given an XML document and a tag //return an Element at a given index NodeList rows = doc.getDocumentElement().getElementsByTagName(tagName); return (Element) rows.item(index); } }