views:

37

answers:

1

Hi, I have a class containing:

[Serializable]
public class ClsStatus
{
     public byte[] Image { get; set; }
     public string Status { get; set; }
     public List<string> Servers { get; set; }
}

Now i am doing:

System.Drawing.Image image = null;
            byte[] imageBytes = null;

        // Create an image of the chart.
        using (MemoryStream s = new MemoryStream())
        {
            chart.ExportToImage(s, System.Drawing.Imaging.ImageFormat.Jpeg);
            image = System.Drawing.Image.FromStream(s);
            imageBytes = s.ToArray();
        }
        ClsStatus status = new ClsStatus();
        List<string> servers = new List<string>();
        servers.Add("Server1");
        servers.Add("Server2");
        servers.Add("Server2");

        status.Image = imageBytes;
        status.Status = "Up & Running";
        status.Servers = servers;

        //XML Serialization
        XmlDocument doc = new XmlDocument();
        XmlSerializer serializer = new XmlSerializer(status.GetType());
        MemoryStream stream = new MemoryStream();
        try
        {
            serializer.Serialize(stream, status);
            stream.Position = 0;
            doc.Load(stream);
            Response.ContentType = "text/xml";
            Response.Clear();
            Response.Write(doc.InnerXml);
        }
        catch
        {
            throw;
        }

My Desired out put and what i am getting fro the above code is here: http://i.imgur.com/YgKgH.jpg

Is there any one who can help me in solving my issue?

Regards, Mohin

+1  A: 

XML is pretty much a text-based format, which means you're not going to be able to "see the image" in your XML document.

The closest you can get is to encode the binary image data into a "text" string (typically through Base64 encoding) and then embed the string into the XML document. That's exactly what you're getting now.

Craig Walker
yeah, i got the answer. Actually what I did was correct and I misunderstood my boss. Thanks for your valuable answer
Mohin