1 package demo.builder; 2 3 import org.w3c.dom.*; 4 5 public class TextMapper 6 { 7 10 public static void map (Node elm, String str) { 11 NodeList nodes = elm.getChildNodes(); 12 for (int i = 0 ; i < nodes.getLength(); i++) { 13 Node node = nodes.item(i); 14 if (node instanceof Text) { 15 Text text = elm.getOwnerDocument().createTextNode(str); 16 elm.replaceChild(text, node); 17 break; 18 } 19 } 20 } 21 } 22 23 | Popular Tags |