我正在作一些小事情,我想弄清楚我是否能夠從字符串加載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