Get Node String Value - Android XML

Android examples for XML:XML Node

Description

Get Node String Value

Demo Code


//package com.java2s;

import org.w3c.dom.*;

public class Main {
    public static String GetStringValue(Node item) throws Exception {
        if (item instanceof Element) {
            Node node = item.getFirstChild();
            if (node != null)
                return node.getNodeValue();
            else// w  w w  . j a  v  a 2s  . c o  m
                return "";
        } else
            throw new Exception(String.format("Cannot handle '%s'.",
                    item.getClass()));
    }
}

Related Tutorials