Page 1 of 1

XML as a data source

Posted: Wed Jun 08, 2016 8:54 pm
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.

Re: XML as a data source

Posted: Thu Jun 09, 2016 8:08 am
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.

Re: XML as a data source

Posted: Thu Jun 09, 2016 2:09 pm
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.

Re: XML as a data source

Posted: Fri Jun 10, 2016 7:53 am
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.

Re: XML as a data source

Posted: Fri Jun 10, 2016 2:10 pm
by muriloruiz
Hello,

Perfect thank you.

Re: XML as a data source

Posted: Fri Jun 10, 2016 5:26 pm
by Alex K.
Hello

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

Thank you.