Extract byte [] from XElement with Linq to Xml
I am storing small images in Xml as byte [] using the following XElement construct.
XElement xe = new XElement("Images",
from c in qry
select new XElement("Image", new XAttribute("Date", c.Date),
new XElement("Data", c.Bytes)));
The Bytes property is byte [], and looking at the resulting element, the contents of the array appear to have been stored just peachy.
My problem is I can't just read this. What is the best way to get this item? Typing in Byte [] seems to be invalid, would I really need to read this as a string? Figure out what encoding to use and convert? It seems to me that given that XElement understands how to write an array, it should read it as well.
0
source to share
2 answers
It was very helpful, thanks. For coding example see:
http://www.nowan.hu/main.aspx?content=9cff1555-26ca-4e6a-910b-6a73463e22b2
+1
source to share