XML Data Report With XML Data Sub Report

Posted by: djomen on 4 August 2017, 3:12 pm EST

  • Posted 4 August 2017, 3:12 pm EST


    I am struggling to get a sub report to work properly and finding the sample and the docs not quite getting me there.

    I have attatched a simple data structure and each main node has a collection of sub nodes that i want to display on a sub report contained on the main report page.

    I either get no nodes or i get all the nodes at that level in the xml tree.

    It must be somethign im getting wrong with the path or the Nodelist on the data source.

    Could you help point out what im doing wrong please?

    On my top level report i am putting //LOCALDATA as the XPath.

    For the data items on customer i am putting CUSTOMER/NAME etc

    What i want then is to pass the ITEMS collection to a sub report datasource as a colelction of nodes.

    On the sub report i want to filter on ItemType too.

    This is the code for getting the sollection of nodes:

    Dim xDS As New DataDynamics.ActiveReports.DataSources.XMLDataSource

    xDS.NodeList = CType(CType(Me.DataSource, DataDynamics.ActiveReports.DataSources.XMLDataSource).Field("ITEMS/ITEM", True), System.Xml.XmlNodeList)

    subRep.Report = New arLocalInfo

    subRep.Report.DataSource = xDS

    CType(subRep.Report, arLocalInfo).ItemType = ItemType.Type1

    The Xpath for the sub report wants to look something like this i believe:

    //ITEM [@ItemType=Type1]

    Tried alsorts of combinations but to no avail.

    Any help appreciated.
  • Replied 4 August 2017, 3:12 pm EST

    To set up this report, I loosely followed the walkthough here: http://www.datadynamics.com/Help/AR2Std/HX_XML_Data_Subreports.html

    On the main report, my XML datasource has a recordset pattern of '//LOCALITEM'.  This points to the top level data node which repeats throughout the XML document.  Now, on the main report I can set datafield properties to 'CUSTOMER/NAME' in order to view the values of each customer.

    Next, I've created a subreport and set its DataField property to 'ITEMS/ITEM'.  This will forward all of the Items inside of the Items node to the subreport.

    On the subreport, the XML control recordset is set to '//ITEM'.  The fields on the subreport have a datafield property of 'NAME', 'ADDRESS1' to get the values of each item.
  • Replied 4 August 2017, 3:12 pm EST

    Thanks for the reply... Almost there! Its doing my head in this... xml is supposed to make things easier! :o)

    If i add the datafield as ITEMS/ITEM and then on the sub report //ITEMS i get all the items in the collection.

    What i need to do now is filter the item type attribute. I did this previously by setting the recordset to //ITEM [@ItemType="Type1"]

    Now the attribute filter is just ignored and i still get all the ITEMS collection.

    I have tried just putting the attribute but it doesnt like that and i get a RTE.
  • Replied 4 August 2017, 3:12 pm EST

    Try setting the filter on the subreport datafield property instead:

    ITEMS/ITEM [@ItemType="Type1"]
  • Replied 4 August 2017, 3:12 pm EST

    Cracked it! Thanks Zach - your a star. Been going round in circles with that for ages.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels