how to send image as a base64 XML item ?

Posted on 2008-11-19
Last Modified: 2013-12-17
I need to retrieve an image from a MySQL field and
communicate it as a base64 XML item.
In the database, the image is stored as a small,
blob field, less than 20k. I can assign it to a string
value without problem. I need to then embed it
in an XML message, as a base64 object.
Question by:pillmill
    LVL 1

    Accepted Solution

    Try the following code ...
    byte[] inboundStringBytes;
    XmlDocument outboundXml;
    string base64String = Convert.ToBase64String(inboundStringBytes);
    XmlNode node = outboundXml.CreateNode(XmlNodeType.Text, "MyImage", "MyNamespaceUri");
    node.Value = base64String;

    Open in new window


    Author Comment

    Would it be possible to do it by reading it the array
    into a dataset and then outputting to an XML object ?

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now