Results 1 to 8 of 8

Thread: QDomDocument.setContent -> .toString Double quotes change to single quotes

  1. #1
    Join Date
    Apr 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QDomDocument.setContent -> .toString Double quotes change to single quotes

    Hi to all!

    I see a strange behaviour when reading and writing XML-Files to and from an QDomDocument.
    What i do is:
    I read a given XML-File which starts with <?xml version="1.0" encoding="iso-8859-1"?> using the QDomDocument.setContent(QFile.....
    Then i do some modifications in the QDomDocument (not necessary to reproduce the behaviour)
    Last i write it out with Stream << QDomDocument.toString(2)

    What i see is that the double quotes in the xml-Declaration (<?xml version="1.0" encoding="iso-8859-1"?>) change in single quotes.

    Anyone any idea where to look for the error?

    Mick

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDomDocument.setContent -> .toString Double quotes change to single quotes

    Why is that an error?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDomDocument.setContent -> .toString Double quotes change to single quotes

    That's exactly what i asked myself yesterday ;-)
    A customer complained about the single quotes and in every example i found there are double quotes in the xml-declaration.
    But you are right. A validation of the xml file with the single qoutes gives no error.
    But why does the QDomDocument write such an unusual syntax?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDomDocument.setContent -> .toString Double quotes change to single quotes

    Probably because it is programmed to work this way Both types of quotes are valid quotes in XML so unless you are working with a broken parser that does not accept sngle quotes, there is no need to worry.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QDomDocument.setContent -> .toString Double quotes change to single quotes

    It would be an error if QDomDocument were changing quotes in element text or CDATA blocks.

    I use QXmlStreamWriter quite a bit and it prefers double quotes. Variety is the spice of life.

  6. #6
    Join Date
    Apr 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDomDocument.setContent -> .toString Double quotes change to single quotes

    Ok, we all agree now that it's no error :-)
    If i can't convince our customer that it's ok how it is, i wil take a look at QXmlStreamWriter.
    Thanks for your help!

    Mick

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QDomDocument.setContent -> .toString Double quotes change to single quotes

    Or you just change the returned string, the processing instruction is the first use of quotes, right?

    Cheers,
    _

  8. #8
    Join Date
    Apr 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDomDocument.setContent -> .toString Double quotes change to single quotes

    Yes, that would be an option. And it's easy to do. If it's the only exception to handle it would be ok.
    Alway when i think of those solutions i feel a kind of dislike. But sometimes one has to accept it ;-)
    Thanks for the hint.

Similar Threads

  1. Quotes matching
    By parulkalra14 in forum Qt Programming
    Replies: 2
    Last Post: 12th March 2014, 06:18
  2. Replies: 2
    Last Post: 5th December 2013, 06:35
  3. Replies: 3
    Last Post: 17th April 2012, 16:05
  4. QSqlQuery escaping single quotes
    By pdoria in forum Qt Programming
    Replies: 0
    Last Post: 1st April 2012, 21:37
  5. QSqlQuery and single quotes using bindValue
    By Luc4 in forum Qt Programming
    Replies: 4
    Last Post: 26th September 2010, 23:34

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.