Java XML Element Value getElementValue(Element element)

Here you can find the source of getElementValue(Element element)

Description

Returns the node value of the element's first child if there is any, otherwise null.

License

BSD License

Parameter

Parameter Description
element the element.

Return

the element's value.

Declaration

public static String getElementValue(Element element) 

Method Source Code


//package com.java2s;
/*/*from  ww w . j a  va 2  s  .  c om*/
 * Copyright (c) 2012. betterFORM Project - http://www.betterform.de
 * Licensed under the terms of BSD License
 */

import org.w3c.dom.*;

public class Main {
    /**
     * Returns the node value of the element's first child if there is any,
     * otherwise <code>null</code>.
     *
     * @param element the element.
     * @return the element's value.
     */
    public static String getElementValue(Element element) {
        Node child = element.getFirstChild();
        if (child != null) {
            return child.getNodeValue();
        }

        return null;
    }
}

Related

  1. getElementValue(Element elem, String path)
  2. getElementValue(Element element)
  3. getElementValue(Element element)
  4. getElementValue(Element element)
  5. getElementValue(Element element)
  6. getElementValue(Element element, String elementName)
  7. getElementValue(Element element, String name)
  8. getElementValue(Element element, String tag)
  9. getElementValue(Element element, String tagName)