sb.append(' ').append(attr.getNodeName() + "=\"" + attr.getNodeValue() + "\"");
sb.append(' '). append(attr.getNodeName()). append("=\""). append(attr.getNodeValue()). append("\"");
   public static String elementToString(Node n) throws XMLException   {      String name = n.getNodeName();      if (name.startsWith("#"))      {         return "";      }      StringBuffer sb = new StringBuffer();      sb.append('<').append(name);      NamedNodeMap attrs = n.getAttributes();      if (attrs != null)      {         for(int i = 0; i < attrs.getLength(); i++)         {            Node attr = attrs.item(i);            sb.append(' ').append(attr.getNodeName() + "=\"" + attr.getNodeValue() + "\"");         }      }      String textContent = null;      NodeList children = n.getChildNodes();      if (children.getLength() == 0)      {         if ((textContent = XMLUtil.getTextContent(n)) != null && !"".equals(textContent))         {            sb.append(textContent).append("</").append(name).append('>');;         }         else         {            sb.append("/>").append('\n');         }      }      else      {         sb.append('>').append('\n');         boolean hasValidChildren = false;         for(int i = 0; i < children.getLength(); i++)         {            String childToString = elementToString(children.item(i));            if (!"".equals(childToString))            {               sb.append(childToString);               hasValidChildren = true;            }         }         if (!hasValidChildren && ((textContent = XMLUtil.getTextContent(n)) != null))         {            sb.append(textContent);         }         sb.append("</").append(name).append('>');      }      return sb.toString();   }