How to create Crystal report from XML (XML from web service) in C #

I want to know how I can create a crystal report from XML (XML from a web service), in some tutorials I read that he needs to find a file and drag and drop fields in the report, but what about XML from a web service?

Here is the code how I get XML from a web service

var doc = XDocument.Parse(trx.GetCardTrx("xxxxx", "xxxx", "xxx", "", dateTimePicker1.Text, dateTimePicker2.Text, "", "", "", "", "", "", "", "", "", "", "", "FALSE", "", "", "", "", "", "", "", "", "", "", "")); MessageBox.Show(doc.ToString()); 

So, this code returns such values ​​( From MessageBox.Show(doc.ToString() )

enter image description here

And here is the code for the selected values ​​that should be in the report

 var summary = from r in doc.Descendants("TrxDetailCard") select new { Account_Type = r.Element("Account_Type_CH").Value, Captured = r.Element("Captured").Value, Trans_Type_ID = r.Element("Trans_Type_ID").Value, Acct_Num_CH = r.Element("Acct_Num_CH").Value, Tip_Amt_MN = r.Element("Tip_Amt_MN").Value, Total_Amt_MN = r.Element("Total_Amt_MN").Value, Date_DT = r.Element("Date_DT").Value, }; 

And I want to create a report using Crystal Reports with these values, not all the values. Only selected values. How can i do this? Any ideas would be of great help Thanks: D

+4
source share
1 answer

This has not been tested, but you can try something like the following

 using System.Xml; using System.Xml.Linq; var doc = XDocument.Parse(trx.GetCardTrx("xxxxx", "xxxx", "xxx", "", dateTimePicker1.Text, dateTimePicker2.Text, "", "", "", "", "", "", "", "", "", "", "", "FALSE", "", "", "", "", "", "", "", "", "", "", "")); var data = new DataSet(); var context = new XmlParserContext(null, new XmlNamespaceManager(new NameTable()), null, XmlSpace.None); var reader = doc data.ReadXml(reader); var report = new ReportDocument(); report.SetDataSource(data); this.crystalReportViewer1.ReportSource.ReportSource = report; 

The idea in theory should work, but you can reference something similar from this link . Crystal Report XML report does not update child objects when updating

+2
source

All Articles