code: public static String serializeNoNS(Node node) {
          StringBuffer buf = new StringBuffer();
          buf.append("<");
          buf.append(node.getLocalName());
          for (Entry<QName, String> entry : getAttributes(node).entrySet()) {
              QName name = entry.getKey();
              if (name.getNamespaceURI() != null) {
                  buf.append(" ");
                  buf.append(name.getLocalPart());
                  buf.append("=\"");
                  buf.append(entry.getValue());
                  buf.append("\"");
              }
          }
          boolean tagOpen = true;
          NodeList children = node.getChildNodes();
          for (int i = 0; i < children.getLength(); i++) {
              Node n = children.item(i);
              short type = node.getNodeType();
              if (type == Node.TEXT_NODE) {
                  if (tagOpen) {
                      buf.append(">\n");
                      tagOpen = false;
                  }
                  buf.append(node.getTextContent());
              } else if (type == Node.ELEMENT_NODE) {
                  if (tagOpen) {
                      buf.append(">\n");
                      tagOpen = false;
                  }
                  buf.append(serializeNoNS(n));
                  buf.append("\n");
              }
          }
          if (tagOpen) {
              buf.append("/>\n");
          } else {
              buf.append("</");
              buf.append(node.getLocalName());
              buf.append(">\n");
          }
          return buf.toString();
          // ByteArrayOutputStream baos = new ByteArrayOutputStream();
          // try {
          // TransformerFactory factory = TransformerFactory.newInstance();
          // File f = Misc.getResourceAsFile("com/occamlab/te/drop-ns.xsl");
          // Transformer transformer = factory.newTransformer(new
          // StreamSource(f));
          //
          // DOMSource src = new DOMSource(node);
          // StreamResult dest = new StreamResult(baos);
          // transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
          // "yes");
          // transformer.transform(src, dest);
          // } catch (Exception e) {
          // System.out.println("Error serializing node.  "+e.getMessage());
          // }
          //
          // return baos.toString();
      }
docs: Serializes a Node to a String