code: public String toXml() throws TwiMLException {
          try {
              Document doc = DocumentBuilderFactory
                  .newInstance()
                  .newDocumentBuilder()
                  .newDocument();
              doc.setXmlStandalone(true);
              doc.appendChild(this.buildXmlElement(doc));
  
              Transformer transformer = TransformerFactory.newInstance().newTransformer();
              transformer.setOutputProperty(OutputKeys.INDENT, "no");
              DOMSource source = new DOMSource(doc);
              StreamResult output = new StreamResult(new StringWriter());
              transformer.transform(source, output);
              return output.getWriter().toString().trim();
          } catch (TransformerException te) {
              throw new TwiMLException("Exception serializing TwiML: " + te.getMessage());
          } catch (Exception e) {
              throw new TwiMLException("Unhandled exception: " + e.getMessage());
          }
      }
docs: Convert TwiML object to XML.
  
  @return XML string of TwiML object
  @throws TwiMLException if cannot generate XML