Get String from XML Element text content - Android XML

Android examples for XML:XML Element

Description

Get String from XML Element text content

Demo Code


import java.util.UUID;
import java.util.logging.Level;
import org.w3c.dom.Element;

public class Main{
    public static String ParseString(Element e) {
        String value = null;/*ww w  .  j  ava  2  s  .c  o  m*/
        try {
            value = e.getTextContent().trim();
        } catch (NumberFormatException ex) {
            Log.log("Preferences.loadXMLFile(): An Exception occured while parsing the string '"
                    + e.getNodeName()
                    + "'. value="
                    + e.getTextContent().trim(), Level.INFO);
        }
        return value;
    }
}

Related Tutorials