Getting data out of a Nested Repeating Section


Badge +2

I need help parsing the data out of a nested repeating section.  I have an expense report form/workflow that I have created.  In it I am trying to allow for a user to allocate a receipt.  The Allocation details are in the nested repeating section. 

172801_pastedImage_1.png

All of my fields are labeled.  I can see them when I do a dump of the xml into a multi-line text field.

172802_pastedImage_2.png

As I process through the steps to use the XML data, I can see the data from the first part of the repeating section, but not the nested section.

172803_pastedImage_3.png

If I try to use the fn-XmlDecode(TravelExpRepeatSectionXML) on the XML data before parsing through the XML data, it looks at my data and only sees one Item rather than 2.

172804_pastedImage_4.png

Will someone please help me to parse through the XML so that I can export the data into useable items.

Thank you!


10 replies

Badge +7

Hi Rebecca,

The nested repeating section will be in the xml but it's encoded so you'll need to manipulate the xml it so it's in a valid format.

If you name your repeating section controls you'll find it easier to find the nested one, I've named the nested control rptTwo in my test version.

In my test version I had to replace the following:

  1. > replaced with >
  2. &amp;lt; replaced with <
  3. &amp;quot; replaced with "
  4. In addition you'll need to remove the duplicate <?xml version="1.0" encoding="utf-8"?> tag you'll then end up with.

So from this...

172807_pastedImage_18.png

I've ended up with this...

172808_pastedImage_19.png

Hope that helps but if you need any more detailed info please let me know.

Jan

Badge +2

Jan,

Thank you for your response.  I have been able to perform steps 1-4 that you provided; however I am still not able to retrieve the data from the nested repeating section.  The last piece that you show, I am not able to do with the Query XML action.  I get an error parsing xml: invalid at the top level of the document.

Thanks!

Badge +7

Hi,

Please can you attach a file with the xml you're trying to parse?

Thanks

Jan

Badge +2

Jan,

Here is the original XML before I do any manipulation to it:

---------

<Item><TravelDate
type="System.DateTime">02/02/2016
00:00:00</TravelDate><TravelPlace type="System.String">test</TravelPlace><TravelAcct
type="System.String">7</TravelAcct><TravelAllocate
type="System.String">Yes</TravelAllocate><TravelBB
type="System.Boolean">False</TravelBB><TravelCostCenter
/><TravelSubLedger /><TravelAmt
type="System.String">100</TravelAmt><TravelAlloc100Percent
type="System.Int32">100</TravelAlloc100Percent><TravelAllocRepeat
type="System.String">&lt;?xml version="1.0"
encoding="utf-8"?&gt;&lt;RepeaterData&gt;&lt;Version
/&gt;&lt;Items&gt;&lt;Item&gt;&lt;TravelAllocPercent
type="System.Int32"&gt;30&lt;/TravelAllocPercent&gt;&lt;TravelAllocBillComments
type="System.String"&gt;&lt;/TravelAllocBillComments&gt;&lt;TravelAllocBB
type="System.Boolean"&gt;True&lt;/TravelAllocBB&gt;&lt;TravelAllocCostCenter
type="System.String"&gt;3&lt;/TravelAllocCostCenter&gt;&lt;TravelAllocSubLedger
type="System.String"&gt;59&lt;/TravelAllocSubLedger&gt;&lt;TravelAllocAmt
type="System.Decimal"&gt;30.00&lt;/TravelAllocAmt&gt;&lt;/Item&gt;&lt;Item&gt;&lt;TravelAllocPercent
type="System.Int32"&gt;30&lt;/TravelAllocPercent&gt;&lt;TravelAllocBillComments
type="System.String"&gt;&lt;/TravelAllocBillComments&gt;&lt;TravelAllocBB
type="System.Boolean"&gt;False&lt;/TravelAllocBB&gt;&lt;TravelAllocCostCenter
/&gt;&lt;TravelAllocSubLedger /&gt;&lt;TravelAllocAmt
type="System.Decimal"&gt;30.00&lt;/TravelAllocAmt&gt;&lt;/Item&gt;&lt;Item&gt;&lt;TravelAllocPercent
type="System.Int32"&gt;40&lt;/TravelAllocPercent&gt;&lt;TravelAllocBillComments
type="System.String"&gt;&lt;/TravelAllocBillComments&gt;&lt;TravelAllocBB
type="System.Boolean"&gt;False&lt;/TravelAllocBB&gt;&lt;TravelAllocCostCenter
/&gt;&lt;TravelAllocSubLedger /&gt;&lt;TravelAllocAmt
type="System.Decimal"&gt;40.00&lt;/TravelAllocAmt&gt;&lt;/Item&gt;&lt;/Items&gt;&lt;/RepeaterData&gt;</TravelAllocRepeat></Item>

----------

Here is the XML after I do the manipulation to it

---------

<Item><TravelDate
type="System.DateTime">02/02/2016
00:00:00</TravelDate><TravelPlace
type="System.String">test</TravelPlace><TravelAcct
type="System.String">7</TravelAcct><TravelAllocate
type="System.String">Yes</TravelAllocate><TravelBB
type="System.Boolean">False</TravelBB><TravelCostCenter
/><TravelSubLedger /><TravelAmt
type="System.String">100</TravelAmt><TravelAlloc100Percent
type="System.Int32">100</TravelAlloc100Percent><TravelAllocRepeat
type="System.String"><RepeaterData><Version
/><Items><Item><TravelAllocPercent
type="System.Int32">30</TravelAllocPercent><TravelAllocBillComments
type="System.String"></TravelAllocBillComments><TravelAllocBB
type="System.Boolean">True</TravelAllocBB><TravelAllocCostCenter
type="System.String">3</TravelAllocCostCenter><TravelAllocSubLedger
type="System.String">59</TravelAllocSubLedger><TravelAllocAmt
type="System.Decimal">30.00</TravelAllocAmt></Item><Item><TravelAllocPercent
type="System.Int32">30</TravelAllocPercent><TravelAllocBillComments
type="System.String"></TravelAllocBillComments><TravelAllocBB
type="System.Boolean">False</TravelAllocBB><TravelAllocCostCenter
/><TravelAllocSubLedger /><TravelAllocAmt
type="System.Decimal">30.00</TravelAllocAmt></Item><Item><TravelAllocPercent
type="System.Int32">40</TravelAllocPercent><TravelAllocBillComments
type="System.String"></TravelAllocBillComments><TravelAllocBB
type="System.Boolean">False</TravelAllocBB><TravelAllocCostCenter
/><TravelAllocSubLedger /><TravelAllocAmt
type="System.Decimal">40.00</TravelAllocAmt></Item></Items></RepeaterData></TravelAllocRepeat></Item>

------------------

Any help is appreciated.

Thanks!

Badge +7

Hi,

I think you've got it right. If I use the Query XML action on your after XML I get this.

175007_pastedImage_0.png

So to get the nested repeater info for the TravelAllocPercent for example you can use the following which loads the data into a collection which you can then query.

175008_pastedImage_2.png

175009_pastedImage_3.png

Hope that helps but let me know if you need any more/different info!

Jan

Badge +2

Am I missing something silly?  When I try to look at the tree view in the XML builder,  I am wondering if this is also related to why I am having issues parsing the data.

errorMsg.jpg

Thanks!

Badge +7

Hi,

So if you parse the following XML:-

<Item><TravelDate

type="System.DateTime">02/02/2016

00:00:00</TravelDate><TravelPlace

type="System.String">test</TravelPlace><TravelAcct

type="System.String">7</TravelAcct><TravelAllocate

type="System.String">Yes</TravelAllocate><TravelBB

type="System.Boolean">False</TravelBB><TravelCostCenter

/><TravelSubLedger /><TravelAmt

type="System.String">100</TravelAmt><TravelAlloc100Percent

type="System.Int32">100</TravelAlloc100Percent><TravelAllocRepeat

type="System.String"><RepeaterData><Version

/><Items><Item><TravelAllocPercent

type="System.Int32">30</TravelAllocPercent><TravelAllocBillComments

type="System.String"></TravelAllocBillComments><TravelAllocBB

type="System.Boolean">True</TravelAllocBB><TravelAllocCostCenter

type="System.String">3</TravelAllocCostCenter><TravelAllocSubLedger

type="System.String">59</TravelAllocSubLedger><TravelAllocAmt

type="System.Decimal">30.00</TravelAllocAmt></Item><Item><TravelAllocPercent

type="System.Int32">30</TravelAllocPercent><TravelAllocBillComments

type="System.String"></TravelAllocBillComments><TravelAllocBB

type="System.Boolean">False</TravelAllocBB><TravelAllocCostCenter

/><TravelAllocSubLedger /><TravelAllocAmt

type="System.Decimal">30.00</TravelAllocAmt></Item><Item><TravelAllocPercent

type="System.Int32">40</TravelAllocPercent><TravelAllocBillComments

type="System.String"></TravelAllocBillComments><TravelAllocBB

type="System.Boolean">False</TravelAllocBB><TravelAllocCostCenter

/><TravelAllocSubLedger /><TravelAllocAmt

type="System.Decimal">40.00</TravelAllocAmt></Item></Items></RepeaterData></TravelAllocRepeat></Item>

using the Query XML action like this:

175389_pastedImage_0.png

Do you get an error in the XPath Builder?

Thanks

Jan

Badge +2

No.  That works!  But I can't expand on the repeating section.

treeView.jpg

Badge +7

Hi,

You'll need to add some logging to your workflow so you can see what you're passing in to the Query XML action.

I guess you have a collection of the outer repeater items you're looping through?

Thanks

Jan

Userlevel 7
Badge +11

Hi Rebecca,

I think the issue you are getting, is that you doing the XmlDecode on the entire data you have.  Instead, what I recommend you do, is use a Query XML action to get all the data out of the node TravelAllocRepeat.  That could probably be done with a simple XPath //TravelAllocRepeat.  Store that in a text variable.

Once you have that, then use a Build String action to do the fn-XmlDecode on your variable.  Store that in a variable (you can store it in the same variable).

Your output be the decoded XML, just for the repeating section. Now you can use the Query XML action to pull data out of the repeating section.

By doing the XmlDecode on the entire data, I think that is messing things up for you and making it harder for you to parse the data.

Vadim

Reply