Results 1 to 8 of 8

Thread: xml with binary question

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default xml with binary question

    Hello all,
    Erm, before I start, I'd just like to say ... "woooh, *nice* forum!"

    anyway, I don't know much about xml, but before I start off learning about Qt XML classes and DOM and stuff, I've got a simple question.
    It would be very handy for me if it were possible to have binary chunks in an xml file. Is that possible or practicable?

    Can I read/write such files with the Qt classes?

    example:
    I'd like to have data in an ordered file so that I can parse to some place in the file to find my data (xml very handy here). The data might 10000 floats (say) and I rather not spend time parsing 10000 bits of text to floats (binary handy here). So, can I just stick binary chunks into an xml file and use the standard parsers.

    any ideas?

    TheKedge

    (and mmmmmh, nice forum!)

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: xml with binary question

    I don't understand the meaning of "inserting binary data in to an xml file"...
    But, from your description, it sounds like you dont need to really parse all the xml data, but that you are only looking for sertain places (where the floats are) in the data.
    If so, I would just use binary file, and use some simple encoding, I would use some bit masks to mark the staring/ending point of the float data or something similar, this way you can run through the binary data very fast and apply bit masks on 32 bits at each time till you find a match, and only then you start "translating" the binary data to floats or what ever.

  3. #3
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: xml with binary question

    Quote Originally Posted by TheKedge
    It would be very handy for me if it were possible to have binary chunks in an xml file. Is that possible or practicable?
    I don't think this is correct!
    XML is a TEXT language for information sharing. In XML you must do define information in text format.

    Bye
    A camel can go 14 days without drink,
    I can't!!!

  4. #4
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: xml with binary question

    Quote Originally Posted by mcosta
    I don't think this is correct!
    XML is a TEXT language for information sharing. In XML you must do define information in text format.
    And your thought is right.
    Quote Originally Posted by TheKedge
    It would be very handy for me if it were possible to have binary chunks in an xml file. Is that possible or practicable?
    Don't mix apples and oranges.
    If you want to use xml then you can put in the tree the offset to the binary data that interest you and then using that ofset access the actual binary data.

  5. #5
    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: xml with binary question

    Of course you may have binary data in xml. All you need to do is to encode it into text (for example using base64 encoding) and place it into CDATA section if it's necessary.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany.
    Posts
    111
    Thanks
    29
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: xml with binary question

    ok, thanks for the help. I'll do it the right way then!

    TheKedge

  7. #7
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: xml with binary question

    Hmm shouldn't have posted before doing my homework:
    There are at least three solutions to this problem:

    * Embed the binary data directly in the XML document using the CDATA tag.
    * Refer to the binary data using a URL.
    * Encode the binary data into a text-based format that can be set as the contents of an XML element.
    http://uk.builder.com/manage/work/0,...0268607,00.htm (and many more if you google around)

  8. #8
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: xml with binary question

    I'm sorry for the little OT of this post, but I think the question is not "Can I put binary data into an XML file?" but "Would I post binary data into an XML file?"
    I mean, what is the reason for putting binary data into an XML file?
    What are the advantages of doing this?
    I think it is not the best way to handle binary data.
    Anyways, this is a full decision of the developer, and the question was answered.

    Sorry for the OT, again.

    Cheers.
    Kandalf
    There's no place like ~

Similar Threads

  1. can`t read a binary data!
    By blm in forum Qt Programming
    Replies: 8
    Last Post: 18th September 2008, 17:56
  2. create personalized binary without having to recompile
    By niko in forum General Programming
    Replies: 8
    Last Post: 6th October 2007, 13:20
  3. OS/X Qt/Mac 3.3.x binary installers
    By hvengel in forum Installation and Deployment
    Replies: 0
    Last Post: 17th September 2007, 01:17
  4. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 17:17

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.