Results 1 to 3 of 3

Thread: XML Problem.

  1. #1
    Join Date
    Jun 2012
    Posts
    41
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Talking XML Problem.

    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.

  2. #2
    Join Date
    Apr 2012
    Location
    Romania
    Posts
    22
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: XML Problem.

    Hello,

    There is nothing missing. The closing tag will be present only when you have an element between the tags. As long as you have only attributes for that tag, the closing tag is given by the last "/" symbol inside your Reg0001 tag
    Best regards,
    Sorin

  3. #3
    Join Date
    Jun 2012
    Posts
    41
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Thumbs up Re: XML Problem.

    Hello, how are you
    Thanks for the help Saurian.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.