Jump to content
Software FX Community

Export to XML generates garbage character


User (Legacy)

Recommended Posts

Hello,

I have the following C# code:

MemoryStream stream = new MemoryStream();

chart1.Export(FileFormat.Xml, stream);

stream.Seek(0, SeekOrigin.Begin);

string xml = Encoding.UTF8.GetString(stream.GetBuffer());

Unfortunately, the first character of the xml string I get back has a trash

ASCII 239 character before the ´<´ that begins the XML. I can trim this

character if there, but is this a bug in the XML export ?

I want to export the personalization data to XML and store myself. I will

store the data as XML so Export to XML seemed natural. Would exporting to

Binary and Base64 encoding be better - that is, be less likely to not Import

successfully if I use an updated version of ChartFX in the future?

Basically I´m trying to minimize the fragility of what I´m getting from

ChartFX via the Export method. I don´t want to export data to find that in

the future I can´t import it to ChartFX v9 or whatever.

Thanks

Mark

Link to comment
Share on other sites

That's the encoding code. The correct way to read that back into a string 

is:

MemoryStream stream = new MemoryStream();

chart1.Export(FileFormat.Xml, stream);

stream.Seek(0, SeekOrigin.Begin);

TextReader reader = new StreamReader(stream);

string xml = reader.ReadToEnd();

--

Francisco Padron

www.chartfx.com

Link to comment
Share on other sites

  • 3 years later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...