Can I store media within an XML file?
-
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:
-
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:
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.
-
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.
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?
-
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?
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.
-
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.
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!