Using XML as DataSource

Thread is closed for posting
6 posts, 0 answers
  1. 77198A19-66D2-4A08-B0C6-A964B92B3D66
    77198A19-66D2-4A08-B0C6-A964B92B3D66 avatar
    1 posts
    Member since:
    Apr 2009

    Posted 13 Apr 2010 Link to this post

    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.
  2. 3BD6F94B-4C03-46D3-8568-9982F1F201BF
    3BD6F94B-4C03-46D3-8568-9982F1F201BF avatar
    10940 posts
    Member since:
    May 2014

    Posted 16 Apr 2010 Link to this post

    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.
  3. 1F02C51D-E36D-42DC-A76F-C096F69EFEA1
    1F02C51D-E36D-42DC-A76F-C096F69EFEA1 avatar
    111 posts
    Member since:
    Mar 2011

    Posted 14 Jul 2011 Link to this post

    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.
  4. 3BD6F94B-4C03-46D3-8568-9982F1F201BF
    3BD6F94B-4C03-46D3-8568-9982F1F201BF avatar
    10940 posts
    Member since:
    May 2014

    Posted 15 Jul 2011 Link to this post

    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!

  5. 3FC828D4-4484-462A-B2C2-4A145A79EA28
    3FC828D4-4484-462A-B2C2-4A145A79EA28 avatar
    46 posts
    Member since:
    Feb 2011

    Posted 02 Jul 2012 Link to this post

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


    Thanks 
  6. CEFFC0B1-FEE4-4169-9954-736CDC079A30
    CEFFC0B1-FEE4-4169-9954-736CDC079A30 avatar
    1 posts
    Member since:
    Jun 2013

    Posted 26 Jun 2013 Link to this post

    Hi Diarmuid

    Thank you for the code.
    Can you show how to add embedded XML file to the project
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.