Here you can find the source of extractOrCreateTextNode(Element filenameElement, String defaultText)
public static Text extractOrCreateTextNode(Element filenameElement, String defaultText)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; public class Main { public static Text extractOrCreateTextNode(Element filenameElement, String defaultText) { Document rootDoc = filenameElement.getOwnerDocument(); if (filenameElement.getChildNodes().item(0) instanceof Text) { return (Text) filenameElement.getChildNodes().item(0); }/* ww w .j a va 2 s .co m*/ Text textNode = rootDoc.createTextNode(defaultText); filenameElement.appendChild(textNode); return textNode; } }