I can’t figure out why this simple lines of code simply doesn’t work:
// Bulding tree
var declaration = new XDeclaration("1.0", "UTF-8", "yes");
var root = new XElement("root");
// Adding elements to document
var doc = new XDocument(declaration, root);
// Salve the stream
var stream = new MemoryStream();
doc.Save(stream);
// Update WebBrowser control
webBrowser1.DocumentStream = stream;
You’re saving to the stream, leaving the “cursor” positioned at the end… and then giving it to the browser, which I suspect is reading from the current location. Try adding:
just before the last line.
EDIT: Okay, you say it’s not working… here’s a short but complete program which works for me. Try this and see if it works for you – and if it does, see if you can work out the difference between your code and this: