我在我试图通过的XDocument
来加载,这样我可以使用LINQ到SQL字符串很简单的XML:
I have very simple XML in a string that I'm trying to load via XDocument
so that I can use LINQ to SQL:
var xmlString = @"<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?>
<person>Test Person</person>";
var doc = XDocument.Load(xmlString); //'Illegal characters in path' error thrown here
我得到一个非法字符的路径
错误抛出,当我尝试加载XML。可能有人请解释为什么发生这种情况?谢谢你。
I get an Illegal characters in path.
error thrown when I try to load the XML; could someone please explain why this is happening? Thanks.
您正在寻找 XDocument.Parse
- XDocument.Load
是文件的不是XML字符串:
You are looking for XDocument.Parse
- XDocument.Load
is for files not xml strings:
var doc = XDocument.Parse(xmlString);