Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# XDocument.Load”文件;路径中的非法字符。”;错误,但当我测试该函数时,存在XML_C#_Xml_Linq To Xml - Fatal编程技术网

C# XDocument.Load”文件;路径中的非法字符。”;错误,但当我测试该函数时,存在XML

C# XDocument.Load”文件;路径中的非法字符。”;错误,但当我测试该函数时,存在XML,c#,xml,linq-to-xml,C#,Xml,Linq To Xml,我在这行代码的路径中获得错误非法字符 var doc = XDocument.Load(openBatch.GetOpenBatchSummary("xxxx", "xxxx", "xxxx", "", "", "")); var summary = from r in doc.Descendants("OpenBatchSummary") select new {

我在这行代码的路径中获得错误非法字符

var doc = XDocument.Load(openBatch.GetOpenBatchSummary("xxxx", "xxxx", "xxxx", "", "", ""));
        var summary = from r in doc.Descendants("OpenBatchSummary")
                      select new
                      {
                          PaymentTypeID = r.Element("Payment_Type_ID"),
                          Return = r.Element("Return"),
                          Sale = r.Element("Sale"),
                      };
        foreach (var i in summary)
        {
            ListViewItem it = new ListViewItem(i.PaymentTypeID.ToString());
            it.SubItems.Add(i.Sale.ToString());
            it.SubItems.Add(i.Return.ToString());
            listView1.Items.Add(it);
        }
但当我通过这行代码测试时,xml数据的

var test = openBatch.GetOpenBatchSummary("xxx", "xxxx", "xxx", "", "", "");
        MessageBox.Show(test);
以下是输出:


使用
XDocument.Parse
,而不是
XDocument.Load
。您正试图以这种方式从文件加载内容。

您能帮我吗?请注意,还有另一个错误“ListViewItem it=new ListViewItem(i.PaymentTypeID.ToString());”谢谢:)@GrayFullBuster尝试将其更改为:
ListViewItem it=new ListViewItem{Content=i.PaymentTypeID.ToString()谢谢,我只是为后代使用了错误的值,我的值有“”这个,我如何删除它?我恐怕无法帮助您,因为我没有完整的XML文档,也没有完整的源代码,也没有详细的错误跟踪。请将
i.PaymentTypeID.ToString()
替换为
(string)i.PaymentTypeID