2,892 questions
If the content is valid, then try this:
MyMemoryStream.Position = 0
MyXDocument = XDocument.Load(MyMemoryStream, LoadOptions.None)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I always use XDocument.Load to load an xml from disk with no issue, but when tried to load the same xml from MemoryStream, always get exception:
MyXDocument = XDocument.Load(MyMemoryStream, LoadOptions.None)
or even:
MyXDocument = XDocument.Parse(Encoding.UTF8.GetString(MyMemoryStream.ToArray), LoadOptions.PreserveWhitespace)
Anyone knows about loading to XDocument from MemoryStream? Thanks :)
If the content is valid, then try this:
MyMemoryStream.Position = 0
MyXDocument = XDocument.Load(MyMemoryStream, LoadOptions.None)