XML as a data source

Stimulsoft Reports.NET discussion
Post Reply
muriloruiz
Posts: 30
Joined: Tue Dec 01, 2015 6:19 pm

XML as a data source

Post by muriloruiz »

Hello!

I would like to create a report using as a data source xml this attached. Today use as a data source connection to SQL, how do I use the xml? They can give me a sample report returning an xml field attached?

Thank you very much.
Attachments
NFe0000148889.xml
(11.81 KiB) Downloaded 206 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: XML as a data source

Post by Alex K. »

Hello,

Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?
You can add the XML connection in the designer and select your .xml file.

In code your code you can use the following code:
report.RegData("Data", dataSet);
report.Dictionary.Synchronize();

Thank you.
Attachments
Capture.PNG
Capture.PNG (24.51 KiB) Viewed 2519 times
muriloruiz
Posts: 30
Joined: Tue Dec 01, 2015 6:19 pm

Re: XML as a data source

Post by muriloruiz »

Good Morning!

This image was exactly as I'd like, each tag xml a field.

Let me explain better, in fact I do not have an .xml file, I do a select in the database in an XML field and would like the xml returned this foce field used in the report as the picture you sent.

Is there a way to do this?

Thank you very much.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: XML as a data source

Post by Alex K. »

Hello,

You can use the following code for load xml from database:

Code: Select all

DataSet dataSet = new DataSet("Data");

XmlDocument xdoc = new XmlDocument();

using (SqlConnection connection = new SqlConnection(@"Data Source=LSK;Initial Catalog=Northwind;Integrated Security=True;User ID=;Password="))
{
    connection.Open();

    string strSQL = @"select XMLData from _00004 where ID = 2";
    SqlCommand command = new SqlCommand(strSQL, connection);
    
    System.Xml.XmlReader reader = command.ExecuteXmlReader();

    if (reader.Read())
        xdoc.Load(reader);
}
var xmlReader = new XmlNodeReader(xdoc);
dataSet.ReadXml(xmlReader);

var report = new StiReport();
report.RegData(dataSet);
report.Dictionary.Synchronize();
report.Design();
Thank you.
Attachments
ReadXMLStringFromDataBase.PNG
ReadXMLStringFromDataBase.PNG (62.46 KiB) Viewed 2511 times
muriloruiz
Posts: 30
Joined: Tue Dec 01, 2015 6:19 pm

Re: XML as a data source

Post by muriloruiz »

Hello,

Perfect thank you.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: XML as a data source

Post by Alex K. »

Hello

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply