forum

Home / DeveloperSection / Forums / assign textwriter to memory writer

assign textwriter to memory writer

Anonymous User197102-Sep-2014

I am writing xml file but missing some value for specific field. i check that when object comes which contains value that specific value exist but after writing xml value doesn't exist. following is the code which is using. I think XmlTextWriter could be the cause of wrong xml. There is another method which could be used for it that is TextWriter but failed to convert it into memorystream.

string xmlString = null;

            MemoryStream memoryStream = new MemoryStream();

            XmlSerializer xs = new XmlSerializer(typeof(T));

           // XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.ASCII);

            TextWriter xmlTextWriter=new StreamWriter(memoryStream,Encoding.ASCII);

            xs.Serialize(xmlTextWriter, obj);

            memoryStream =(MemoryStream)xmlTextWriter.   //(MemoryStream)xmlTextWriter.BaseStream;

            xmlString = ASCIIByteArrayToString(memoryStream.ToArray()); return `xmlString;`

Any idea how i can know why and where the problem occur.


Updated on 02-Sep-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By