Hi all,
I'm trying to convert the xml obtained from a XmlReader object into a UTF-8
array. My general idea is to read the XmlReader and write into a
MemoryStream. Then convert the MemoryStream bytes into utf-8.
MemoryStream ms = new MemoryStream();
XmlTextWriter xmlWriter = new XmlTextWriter(ms, new UTF8Encoding(false));
writer.Formatting = Formatting.Indented;
writer.Namespaces = false;
writer.Indentation = 4;
while(xmlReader.Read())
{
xmlWriter.Write(?);
}
xmlWriter.Flush();
xmlWriter.Close();
string xml_as_utf8 = Encoding.UTF8.GetString(ms.ToArray());
But I fill the XmlReader and XmlWriter are not made for this purpose.
xmlReader.Read() parses the xml stream, and xmlWriter is done to create xml
element by element.
Which is the correct strategy here?
Thanks in advance
Sammy