BabelFish
BabelFish

Reputation: 909

XElement with System.Data.Linq.Binary

I am making an XElement with an element that has LINQ.Binary in it..

The line looks like:

new XElement("Data", binData));

Where binData is of type System.Data.Linq.Binary

what I dont understand is that when I look at the xml created it shows

<Data>"mydata"</Data>

instead of

<Data>mydata</Data>

why are there quotes and how do I get rid of them.

Upvotes: 1

Views: 691

Answers (1)

Matt Ellen
Matt Ellen

Reputation: 11612

The reason you are getting "mydata" is because that is what the output of System.Data.Linq.Binary's ToString() method gives you.

This is a simple way to get rid of them, although plenty of others exist:

string bindatastr = binData.ToString();
new XElement("Data", bindatastr.Substring(1, bindatastr.Length - 2));

Upvotes: 1

Related Questions