Here you can find the source of getElementValue(final Element target)
Parameter | Description |
---|---|
target | - the element |
public static String getElementValue(final Element target)
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; public class Main { /**/*from w ww . jav a 2 s. c o m*/ * returns the text value associated with the element * * @param target - the element * @return - the text value */ public static String getElementValue(final Element target) { final NodeList nodeList = target.getChildNodes(); if (nodeList == null) { return null; } for (int current = 0; current < nodeList.getLength(); current++) { final Node node = nodeList.item(current); if (node instanceof Text) { final Text text = (Text) node; final String value = text.getNodeValue(); if ((value != null) && (!value.isEmpty())) { return value; } } } return ""; } }