title: Empty XML is created while using DOM to create XML
body: <p>I am trying to create a xml using DOM Parser. Below is the code where i create XML. But i am getting an xml which only has the xml version as given below:</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  </code></pre>
  
  <p>The code used to generate the xml is as below:</p>
  
  <pre><code>private void createTestngXML() throws Exception {
      try {
          DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
          DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
          Document document = documentBuilder.newDocument();
          document.setXmlVersion("1.0");
  
          Element root = document.createElement("suite");
          root.setAttribute("name", "MasterDataSuite");
          root.setAttribute("verbose", "1");
  
          Element testnode = document.createElement("test");
          testnode.setAttribute("name", "MasterDataTests");
          root.appendChild(testnode);
  
          Element classesNode = document.createElement("classes");
          testnode.appendChild(classesNode);
  
          Element classNode = document.createElement("class");
          classNode.setAttribute("com.test.suite.TestSuite1.java");
          classesNode.appendChild(classNode);
  
          Element classNode = document.createElement("class");
          classNode.setAttribute("com.test.suite.TestSuite2.java");
          classesNode.appendChild(classNode);
  
          document.appendChild(root);
  
          DOMSource source = new DOMSource(document);
          TransformerFactory transformerFactory = 
          TransformerFactory.newInstance();
          Transformer transformer = transformerFactory.newTransformer();
          StreamResult result = new StreamResult(new File("D:\\testng.xml"));
          transformer.transform(source, result);
      } catch (Exception ex) {
          throw ex;
      }
  }
  </code></pre>
  
  <p>But the nodes created are not generated in the xml file. What am i doing wrong?</p>