Results 1 to 7 of 7

Thread: Generate encoding code..

  1. #1
    Join Date
    Jul 2008
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy Generate encoding code..

    How to generate <?xml version="1.0" encoding="UTF-8" standalone="0" ?> in xml using Dom or XMLStreamWriter????


    Can i have a sample of it.. thanks...

    Cos i don noe how to code the part...

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Generate encoding code..

    You can add it before setting content,,,

    like if u have xml data in xmlData,
    you can write - xmlData.prepend("<?xml version="1.0" encoding="UTF-8" standalone="0" ?>");

    and then write to QDomDocument.

  3. #3
    Join Date
    Jul 2008
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Generate encoding code..

    thanks... for xmlData need any lib???

  4. #4
    Join Date
    Jul 2008
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Generate encoding code..

    xmlData is the file or xml??

    is it QXmlStreamWriter xmlData;
    xmlData.prepend("<?xml .. .. .. ?>");

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Generate encoding code..

    xmlData is ur QString.
    refere QDomDocument::setContent()

  6. #6
    Join Date
    Jul 2008
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Generate encoding code..

    Im almost getting correct. can i ask how to insert the QString into the first line of the xml file??

    Is it using the "insertBefore(newValue,referValue);" ??

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Generate encoding code..

    See QDomDocument::createProcessingInstruction():
    Qt Code:
    1. QDomProcessingInstruction pi = doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" standalone=\"0\"");
    2. doc.appendChild(pi);
    3. qDebug() << doc.toString();
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  2. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  3. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21:41

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.