从String填充XDocument

我正在作一些小事情,我想弄清楚我是否能够从字符串加载XDocument。 XDocument.Load()彷佛将传递给它的字符串做为物理XML文件的路径。 spa

我想尝试绕过首先必须建立物理XML文件的步骤,而后直接跳转到填充XDocument。 code

有任何想法吗? 文档


#1楼

您可使用XDocument.Parse字符串


#2楼

您可使用XDocument.Parse(string)而不是Load(string)get


#3楼

尝试Parse方法。 string


#4楼

这个怎么样...? it

TextReader tr = new StringReader("<Root>Content</Root>");
XDocument doc = XDocument.Load(tr);
Console.WriteLine(doc);

这是从XDNocument.Load的MSDN文档中获取的,在这里找到... io

http://msdn.microsoft.com/en-us/library/bb299692.aspx bug

相关文章
相关标签/搜索