String textContent = null;
   public static String getTextContent(Node n) throws XMLException   {      if (n.hasChildNodes())      {         StringBuffer sb = new StringBuffer();         NodeList nl = n.getChildNodes();         for(int i = 0; i < nl.getLength(); i++)         {            sb.append(XMLUtil.elementToString(nl.item(i)));            if (i < nl.getLength() - 1)            {               sb.append('\n');            }         }         String s = sb.toString();         if (s.length() != 0)         {            return s;         }      }      Method[] methods = Node.class.getMethods();      for(int i = 0; i < methods.length; i++)      {         if("getTextContent".equals(methods[i].getName()))         {            Method getTextContext = methods[i];            try            {               return (String)getTextContext.invoke(n, EMPTY_ARRAY);            }            catch(Exception e)            {               log.error("Failed to invoke getTextContent() on node " + n, e);               return null;            }         }      }      // JDK 1.4      String s = n.toString();      int i = s.indexOf('>');      int i2 = s.indexOf("</");      if (i == -1 || i2 == -1)      {         return null;      }      return s.substring(i + 1, i2);   }