Hi guys.
I have a little problem and would like your help.
My code creates the XML file in this format:

I think the closing tag (<\ Reg0001>) is missing on some lines?
Where am I going wrong?

Qt Code:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE Cadastro>
  3. <Cadastros_Empresas Version="1.0">
  4. <Reg0001 Codigo="0001">
  5. <Reg0001 Grupo="G0001"/> ##(Missing a completion tag -> <\Reg0001>)
  6. <Reg0001 Nome_Fantasia="Suportek"/> ##(Missing a completion tag -> <\Reg0001>)
  7. <Reg0001 CNPJ="78.425.986/0036-15"/> ##(Missing a completion tag -> <\Reg0001>)
  8. <Reg0001 tbRepresentantes="Representantes">
  9. <Reg0001 Nome="Ernande Alexandre. P. Santana" CPF="111.111.111-01" FONE01="(81) 98877.5577" FONE02="(81) 95544.6699"/> ##(Missing a completion tag -> <\Reg0001>)
  10. </Reg0001>
  11. <Reg0001 tbSocios="Socios">
  12. <Reg0001 Socio="Ernande Alexandre. P. Santana" CPF="111.111.111-01" FONE01="(81) 98877.5577" FONE02="(81) 95544.6699"/> ##(Missing a completion tag -> <\Reg0001>)
  13. <Reg0001 Socio="Jorgenete Santana" CPF="222.222.222-02" FONE01="(81) 91177.2277" FONE02="(81) 96644.9999"/> ##(Missing a completion tag -> <\Reg0001>)
  14. </Reg0001>
  15. </Reg0001>
  16. </Cadastros_Empresas>
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. stream.writeStartElement("Cadastros_Empresas");
  2. stream.writeAttribute("Version", "1.0");
  3.  
  4. stream.writeStartElement("Reg0001");
  5. stream.writeAttribute("Codigo", "0001");
  6.  
  7. stream.writeStartElement("Reg0001");
  8. stream.writeAttribute("Grupo", "G0001");
  9. stream.writeEndElement();
  10. stream.writeStartElement("Reg0001");
  11. stream.writeAttribute("Nome_Fantasia", "Suportek");
  12. stream.writeEndElement();
  13. stream.writeStartElement("Reg0001");
  14. stream.writeAttribute("CNPJ", "78.425.986/0036-15");
  15. stream.writeEndElement();
  16.  
  17. // TABELA REPRESENTANTES
  18. {
  19. stream.writeStartElement("Reg0001");
  20. stream.writeAttribute("tbRepresentantes", "Representantes");
  21. stream.writeStartElement("Reg0001");
  22. stream.writeAttribute("Nome", "Ernande Alexandre. P. Santana");
  23. stream.writeAttribute("CPF", "111.111.111-01");
  24. stream.writeAttribute("FONE01", "(81) 98877.5577");
  25. stream.writeAttribute("FONE02", "(81) 95544.6699");
  26. stream.writeEndElement();
  27. stream.writeEndElement();
  28. }
  29. // TABELA SOCIOS
  30. {
  31. stream.writeStartElement("Reg0001");
  32. stream.writeAttribute("tbSocios", "Socios");
  33. stream.writeStartElement("Reg0001");
  34. stream.writeAttribute("Socio", "Ernande Alexandre. P. Santana");
  35. stream.writeAttribute("CPF", "111.111.111-01");
  36. stream.writeAttribute("FONE01", "(81) 98877.5577");
  37. stream.writeAttribute("FONE02", "(81) 95544.6699");
  38. stream.writeEndElement();
  39.  
  40. stream.writeStartElement("Reg0001");
  41. stream.writeAttribute("Socio", "Jorgenete Santana");
  42. stream.writeAttribute("CPF", "222.222.222-02");
  43. stream.writeAttribute("FONE01", "(81) 91177.2277");
  44. stream.writeAttribute("FONE02", "(81) 96644.9999");
  45. stream.writeEndElement();
  46. stream.writeEndElement();
  47. }
  48. stream.writeEndElement(); // Reg0001
  49. stream.writeEndElement(); // Cadastros_Empresas
  50. stream.writeEndDocument();
To copy to clipboard, switch view to plain text mode 

Where am I going wrong?

Thank you in advance.