好的,所以我正在通过执行将文件缓存在内存中
byte[] file = System.IO.File.ReadAllBytes("test.xml");
然后稍后我尝试从该缓冲区创建一个 xml 文档,如下所示:
System.IO.MemoryStream stream = new System.IO.MemoryStream(file);
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(stream);
System.Xml.Linq.XDocument xPartDocument = new System.Xml.Linq.XDocument(reader);
但这无法创建文档,但有以下例外:
A first chance exception of type 'System.ArgumentException' occurred in System.Xml.Linq.dll Additional information: Non white space characters cannot be added to content.
然而,'reader' 看起来是错误的,即在本地人中它的值是 'None':
- 阅读器 {无} System.Xml.XmlTextReader
此外,“文件”字节数组变量具有 11 个字节的标题(我认为这只是 txt 文件标题?):
0x0393B148 58 35 59 71 X5Yq
0x0393B14C dc 67 01 00 Üg..
0x0393B150 ef bb bf 3c <
0x0393B154 3f 78 6d 6c ?xml
0x0393B158 20 76 65 72 ver
非常感谢任何帮助。
谢谢