Results 1 to 4 of 4

Thread: QDomElement to QByteArray ?

  1. #1
    Join Date
    Jan 2006
    Posts
    185
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDomElement to QByteArray ?

    I am parsing a QByteArray. Inside the QByteArray there is text in XML form.

    At some point in this XML, there is an Element that I want to consider and use it as QByteArray. The other Elements are used as text, therefore I can conver the element to text by doing something like: e.text();

    How can I use the element and keep it as QByteArray ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDomElement to QByteArray ?

    Either use a CDATA section or encode your byte array in some way, so that it uses only ASCII characters (the easiest solution is to use BASE64, because Qt would do the conversion for you, but you also convert each byte to a hex value).

  3. #3
    Join Date
    Jan 2006
    Posts
    185
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDomElement to QByteArray ?

    Inside the XML element there is an image, so I do not want to convert it to Ascii.

    I want to treat the element as QByteArray.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDomElement to QByteArray ?

    XML is text, not binary data. Either convert that QByteArray to text or try CDATA section.

Similar Threads

  1. storing integer 4bytes in QByteArray
    By babu198649 in forum Newbie
    Replies: 2
    Last Post: 30th November 2008, 10:08
  2. QByteArray problem
    By Misenko in forum Qt Programming
    Replies: 17
    Last Post: 4th October 2008, 21:53
  3. QDomElement
    By sabeesh in forum Qt Programming
    Replies: 4
    Last Post: 20th September 2007, 12:55
  4. QByteArray with network data
    By merlvingian in forum Qt Programming
    Replies: 1
    Last Post: 1st June 2007, 17:53
  5. Reading QByteArray from QDataStream Qt3.3
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2006, 20:23

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.