1 16 package org.directwebremoting.util; 17 18 import org.w3c.dom.CharacterData ; 19 import org.w3c.dom.Comment ; 20 import org.w3c.dom.EntityReference ; 21 import org.w3c.dom.Node ; 22 import org.w3c.dom.NodeList ; 23 24 29 public class DomUtil 30 { 31 37 public static String getText(Node node) 38 { 39 StringBuffer reply = new StringBuffer (); 40 41 NodeList children = node.getChildNodes(); 42 for (int i = 0; i < children.getLength(); i++) 43 { 44 Node child = children.item(i); 45 46 if ((child instanceof CharacterData && !(child instanceof Comment )) || child instanceof EntityReference ) 47 { 48 reply.append(child.getNodeValue()); 49 } 50 else if (child.getNodeType() == Node.ELEMENT_NODE) 51 { 52 reply.append(getText(child)); 53 } 54 } 55 56 return reply.toString(); 57 } 58 } 59 | Popular Tags |