public static void replaceTextWithCData(Document doc, Node node) {
    """
	Replace all text values of a {@link Node} with CDATA values.
	
	@param doc  the document to update
	@param node the node to update
    """
        if (node instanceof Text) {
            Text text = (Text) node;
            CDATASection cdata = doc.createCDATASection(text.getTextContent());
            Element parent = (Element) text.getParentNode();
            parent.replaceChild(cdata, text);
        } else if (node instanceof Element) {
            //LOGGER.debug( "ELEMENT " + element.getTagName() );
            NodeList children = node.getChildNodes();
            for (int i = 0; i < children.getLength(); i++) {
                //LOGGER.debug( "> " + children.item( i ).getClass().getName() );
                XmlUtils.replaceTextWithCData(doc, children.item(i));
            }
        }
    }
public static void replaceTextWithCData(Document doc, Node node) {
        if (node instanceof Text) {
            Text text = (Text) node;
            CDATASection cdata = doc.createCDATASection(text.getTextContent());
            Element parent = (Element) text.getParentNode();
            parent.replaceChild(cdata, text);
        } else if (node instanceof Element) {
            //LOGGER.debug( "ELEMENT " + element.getTagName() );
            NodeList children = node.getChildNodes();
            for (int i = 0; i < children.getLength(); i++) {
                //LOGGER.debug( "> " + children.item( i ).getClass().getName() );
                XmlUtils.replaceTextWithCData(doc, children.item(i));
            }
        }
    }
public static void replaceTextWithCData ( Document doc , Node node ) { if ( node instanceof Text ) { Text text = ( Text ) node ; CDATASection cdata = doc . createCDATASection ( text . getTextContent ( ) ) ; Element parent = ( Element ) text . getParentNode ( ) ; parent . replaceChild ( cdata , text ) ; } else if ( node instanceof Element ) { //LOGGER.debug( "ELEMENT " + element.getTagName() ); NodeList children = node . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { //LOGGER.debug( "> " + children.item( i ).getClass().getName() ); XmlUtils . replaceTextWithCData ( doc , children . item ( i ) ) ; } } }
Replace all text values of a {@link Node} with CDATA values.

@param doc  the document to update
@param node the node to update
Replace all text values of a { @link Node } with CDATA values .