Java XML CData getCharacterDataFromElementWithKey(final Element element, final String key)

Here you can find the source of getCharacterDataFromElementWithKey(final Element element, final String key)

Description

get Character Data From Element With Key

License

Open Source License

Declaration

public static String getCharacterDataFromElementWithKey(final Element element, final String key) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.CharacterData;

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static String getCharacterDataFromElementWithKey(final Element element, final String key) {
        String result = null;/*from www  . j  a  va2  s . c o  m*/
        if (element != null) {
            final NodeList jobNodeList = element.getElementsByTagName(key);

            final Node node = jobNodeList.item(0);
            if (node != null) {
                final CharacterData characterData = (CharacterData) jobNodeList.item(0).getChildNodes().item(0);
                if (characterData != null) {
                    result = characterData.getNodeValue();
                }
            }
        }
        return result;
    }
}

Related

  1. createNewCDATAElement(Node elem, String tag, String value)
  2. getCharacterData(Element el)
  3. getCharacterDataFromElement(Element e)
  4. getCharacterDataFromElement(Element e)
  5. getCharacterDataFromElement(Element e)
  6. isCDataOrText(int nodeType)
  7. parseCdataSection(Node cdataParentNode)
  8. removeEmptyCDATASections(Node node)
  9. setTextValue(Node node, String value, boolean cdata)