Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Can I store media within an XML file?

Can I store media within an XML file?

Scheduled Pinned Locked Moved XML / XSL
databasexmltutorialquestion
5 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EvanSaunders
    wrote on last edited by
    #1

    Hi There I am new to XML and related technologies. :doh: I would like to know if it is possible to store media files within an XML file? From what I know, most data stored within an XML file is textural based. If one converts a database file, Excel sheet, etc. into an XML file, it simply stores this data in a textural format. Does this mean that if I store an image (for example) within the XML file, it stores it as the textural representation of that image, or as a link to that image? Or is there a way of storing it within the XML file? (also, does the same apply to video, audio - mp3, midi, wav, etc, and all other media files) Thanks in advance :thumbsup:

    S 1 Reply Last reply
    0
    • E EvanSaunders

      Hi There I am new to XML and related technologies. :doh: I would like to know if it is possible to store media files within an XML file? From what I know, most data stored within an XML file is textural based. If one converts a database file, Excel sheet, etc. into an XML file, it simply stores this data in a textural format. Does this mean that if I store an image (for example) within the XML file, it stores it as the textural representation of that image, or as a link to that image? Or is there a way of storing it within the XML file? (also, does the same apply to video, audio - mp3, midi, wav, etc, and all other media files) Thanks in advance :thumbsup:

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      Hi, it is possible to store media files within an XML file. As you already mentioned the textual representation of the file will be stored. A media file is a binary representation of the media itself. This binary representation can be stored on a sheet of paper, a database or an XML file. I suggest that you convert the binary representation of the file into a base64 encoded string (use Convert.ToBase64String) and place that string in an XML element. Let me know if you need further details. Regards Sebastian

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      E 2 Replies Last reply
      0
      • S SeMartens

        Hi, it is possible to store media files within an XML file. As you already mentioned the textual representation of the file will be stored. A media file is a binary representation of the media itself. This binary representation can be stored on a sheet of paper, a database or an XML file. I suggest that you convert the binary representation of the file into a base64 encoded string (use Convert.ToBase64String) and place that string in an XML element. Let me know if you need further details. Regards Sebastian

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        E Offline
        E Offline
        EvanSaunders
        wrote on last edited by
        #3

        Thanks for the advice...much appreciated. I found a program that can convert an image to base64 string, and I can then embed this within the XML file. I tried programming this myself in order to be able to convert files of any media format (images, audio, video, etc.) I am kinda stuck trying to use the Convert.ToBase64String. I am trying to get an array of bytes from the image file to put in as a parameter for the Convert method. The only array I can get from the image in the form of 'Guid' type. Is the any other way of converting an image (and other files) to base64 string format?

        S 1 Reply Last reply
        0
        • E EvanSaunders

          Thanks for the advice...much appreciated. I found a program that can convert an image to base64 string, and I can then embed this within the XML file. I tried programming this myself in order to be able to convert files of any media format (images, audio, video, etc.) I am kinda stuck trying to use the Convert.ToBase64String. I am trying to get an array of bytes from the image file to put in as a parameter for the Convert method. The only array I can get from the image in the form of 'Guid' type. Is the any other way of converting an image (and other files) to base64 string format?

          S Offline
          S Offline
          SeMartens
          wrote on last edited by
          #4

          You need to read the media file as byte array, because the Convert.ToBase64String takes a byte-array as input. To read the content of a file in an array have a look here: http://www.yoda.arachsys.com/csharp/readbinary.html[^] Regards Sebastian

          It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

          1 Reply Last reply
          0
          • S SeMartens

            Hi, it is possible to store media files within an XML file. As you already mentioned the textual representation of the file will be stored. A media file is a binary representation of the media itself. This binary representation can be stored on a sheet of paper, a database or an XML file. I suggest that you convert the binary representation of the file into a base64 encoded string (use Convert.ToBase64String) and place that string in an XML element. Let me know if you need further details. Regards Sebastian

            It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

            E Offline
            E Offline
            EvanSaunders
            wrote on last edited by
            #5

            Hi Again I managed to get it working...both the conversion to XML and back to it's original file. Thanks for the help...much appreciated!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups