Here you can find the source of getCdata(Element elem)
Parameter | Description |
---|---|
elem | the parent Element |
public static String getCdata(Element elem)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import org.w3c.dom.CharacterData; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**// w w w .j av a 2s . c om * Extracts the first CDATA child from the given {@code org.w3c.dom.Element}. * * @param elem the parent Element * @return the String value of the CDATA section, or {@code null} if none * found */ public static String getCdata(Element elem) { NodeList nodes = elem.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node.getNodeType() == Node.CDATA_SECTION_NODE) { CharacterData cdataNode = (CharacterData) node; return cdataNode.getData(); } } return null; } }