get Element and return a string from XML Element - Android XML

Android examples for XML:XML Element

Description

get Element and return a string from XML Element

Demo Code


//package com.java2s;
import org.w3c.dom.Element;

public class Main {
    public static String getElement(Element e, String name) {
        if (e.getElementsByTagName(name) == null)
            return "";
        if (e.getElementsByTagName(name).item(0) == null)
            return "";
        return e.getElementsByTagName(name).item(0).getTextContent();
    }/*from w w  w .  j a v  a 2 s.  c  o m*/
}

Related Tutorials