我正在作一些小事情,我想弄清楚我是否能够从字符串加载XDocument。 XDocument.Load()
彷佛将传递给它的字符串做为物理XML文件的路径。 spa
我想尝试绕过首先必须建立物理XML文件的步骤,而后直接跳转到填充XDocument。 code
有任何想法吗? 文档
您可使用XDocument.Parse
。 字符串
您可使用XDocument.Parse(string)
而不是Load(string)
。 get
尝试Parse方法。 string
这个怎么样...? it
TextReader tr = new StringReader("<Root>Content</Root>"); XDocument doc = XDocument.Load(tr); Console.WriteLine(doc);
这是从XDNocument.Load的MSDN文档中获取的,在这里找到... io