Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XDocument.Load "Illegal characters in path." Error, but when I test the function there is the XML

I get error illegal characters in path with this line of code

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);
        }

But when I test the through this line of code there is the xml data's

var test = openBatch.GetOpenBatchSummary("xxx", "xxxx", "xxx", "", "", "");
        MessageBox.Show(test);

And here is the output:

enter image description here

like image 888
GrayFullBuster Avatar asked Dec 18 '12 02:12

GrayFullBuster


1 Answers

Use XDocument.Parse, not XDocument.Load. You are trying to load the content from a file that way.

like image 55
Mir Avatar answered Dec 14 '22 23:12

Mir