Gets tag value from XML entry. - Android XML

Android examples for XML:XML Tag

Description

Gets tag value from XML entry.

Demo Code


//package com.java2s;

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class Main {
    /**//  ww  w .  j a  va 2s  . c  o  m
     * Gets tag value from XML entry.
     * @param tag         XML tag String.
     * @param xmlElement   XML Element Object.
     * @return            Integer.parseInt(((Node) lastNodeList.item(0)).getNodeValue()).
     */
    public static String getEntry(String tag, Element xmlElement) {
        NodeList nodeList = xmlElement.getElementsByTagName(tag);
        Element element = (Element) nodeList.item(0);
        NodeList lastNodeList = element.getChildNodes();
        return lastNodeList.item(0).getNodeValue();
    }
}

Related Tutorials