recently I was working in a project where the requirement was save "trdx" files into a DB and show them in a asp.net web form application. As additional information, the data to populate the reports were in XML files.
so I realized to late that "Telerik reporting" doesn't accept xml as datasource or at least I couldn't find a direct way to achieve that. I read that you can transform the xml into objectdatasource but it was little complicated due the dynamism in the project.
at the end I decided to work with a user function that basically accept two parameters
- XPathExpression => the xpath query to find the data in the xml string
- xmlDocument => the xml string, I pass it to my report by a parameter.
The function :
, Namespace =
, Description =
"Find the information from the default report parameter XmlDataSource using XPath expressions "
XmlDocument xmlDoc =
XmlDocument newDom =
System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline));
xmlXPathValue = newDom.SelectSingleNode(XPathExpression) !=
? newDom.SelectSingleNode(XPathExpression).Value :
//a pretty ans secret way to catch exceptions
How to use in expression:
= XmlTelerikReporting.XmlValue( "//@parametertofind" , Parameters.xmlDocument.Value )
I will really appreciate any feedback regarding to my code display above.
and it will be awesome if you implement something in telerik reporting in order to accept XML files as Datasource