Hello everyone,
I am using the following code to retrieve the string content of XML, my question is why there is many trailing zeros in variable content? How to solve it?
[Code] static void Main(string[] args) { MemoryStream MemoryStream1 = new MemoryStream(); StreamWriter StreamWriter1 = new StreamWriter(MemoryStream1); XmlTextWriter XMLWriter1 = new XmlTextWriter(StreamWriter1);
XMLWriter1.WriteStartDocument();
XMLWriter1.WriteStartElement("Entity"); //root element XMLWriter1.WriteAttributeString("node", "Hello Node");
//root ending XMLWriter1.WriteEndElement(); XMLWriter1.WriteEndDocument();
//flush the buffer to underlying stream XMLWriter1.Flush();
string content = Encoding.UTF8.GetString(MemoryStream1.GetBuffer());
return;
}[/Code]
thanks in advance,George