Skip Navigation LinksHome / Community & Support / Code Library / Telerik Reporting > General and Integration Projects > Using XML as DataSource

Not answered Using XML as DataSource

Feed from this thread
  • Posted on Apr 13, 2010 (permalink)

    Requirements

    Telerik Reporting version

    Reporting Q3 2009+

    .NET version

    3.5 SP 1

    Visual Studio version

    VS 2008 Professional +

    programming language

    C#

    To convert code

    Telerik online converter


    PROJECT DESCRIPTION
    This simple report outlines how to read data from an XML file rather than directly from a DataBase. It also shows a useful example of how to manipulate the individual items of a pie chart using code.

    The report basically reads data from an xml source and uses it to generate a pie chart and a table.

    You can either read the xml from the embedded xml file (as contained in the Data folder), or you can pass in an xml string by calling the public SaveReport function. Here are the 2 options for reading the xml data :

    // Read from the embedded XML file
     
    var assembly = Assembly .GetExecutingAssembly();
    var stream = assembly.GetManifestResourceStream("ClassLibrary1.Data.Report.xml");
    var xml = XDocument.Load(new StreamReader(stream));
     
    //Read the data from inputted XML string
     
    var xml = XDocument.Load(new StringReader(xmlString));
     
    //The data can then be held in a pre-defined class. (These are defined in the Entities.cs class)
     
    // Query the XML data
     
     
    var cover1 = from c in xml.Descendants("CoverBreakdown")
     
     
    select new CoverBreakDownDS
     
    {
    Description = c.Element("Description").Value,
    Value = Convert.ToDouble(c.Element("Value").Value),
    };

    Once the data is residing in the pre-defined classes, it can be assigned as the data source for the different elements of the report. You would have to add an ASP.NET, Windows Forms or Silverlight application to the project in order to view the report.
    Attached files

    Reply

  • Steve Steve avatar

    Posted on Apr 16, 2010 (permalink)

    Hi Diarmuid,

    Thank you for the provided project and explanation. It will be of help for the other members of the Telerik community and will bring additional value to our product. I have updated your Telerik points for the involvement.

    All the best,
    Steve
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

    Reply

  • Allen avatar

    Posted on Jul 14, 2011 (permalink)

    It is really difficult to believe that setting an Xml file as the datasource for a report could possibly require so much effort.  Am I missing something obvious?

    I expected:

    1) select an Xml file
    2) possibly, create a Xml document from it (maybe?)
    3) associate a report object with the file/ document?
    4) pick document elements/attributes whatever to include in the report
    5) Decorate
    6) Save the file
    7) Show

    but what this example shows is world of hurt to do something basic.  Please advise.  Thank you.

    Reply

  • Steve Steve avatar

    Posted on Jul 15, 2011 (permalink)

    Hi Allen,

    The code library section does not aim to show you best practices. It's a place for exchanging code samples, sharing knowledge and getting hands-on experience.
    Also as noted in the Policies and Disclaimers section, projects posted by clients will NOT be supported by Telerik. In case you have a question about certain implementation with our product, please start a new support ticket.
    Specifically for your inquiry, check the following help article: Does Telerik Reporting support XML as a datasource i.e. create a typed DataSet from your XML and use the ObjectDataSource Component to bind to it as explained in the How to: Bind to a DataSet help article.

    Regards,
    Steve
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

    Reply

  • TMatt Intermediate avatar

    Posted on Jul 2, 2012 (permalink)

    Any real example would help.
    We have to solve the same . To Format an XML which can grab via http


    Thanks 

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / Telerik Reporting > General and Integration Projects > Using XML as DataSource