There's no other way than replacing all the encoded characters with their non-encoded characters actually.
You can use a replace string to do that :
- & --> & (do this first)
- > --> >
- < --> <
- " --> "
- etc.
It is a pain to do it, but you cannot use xmldecode, which does not exists.
Hi, you should be able to parse the nested repeating section but might have to run the fn-xmlDecode function a few times. Can you please upload your XML as text rather than an image? We'll give it a go with your exact XML.
I had a bit of spare time so I tried to recreate your form - this is a good example of managing repeating sections within repeating sections so hopefully a good resource for many people. The key is the repeating sections are stored as XML but some manipulation is needed to get the XML that you need. I must say, this posed an additional fun challenge in trying to read the XML you provided which is in Norwegian or Danish (I couldn't figure out which). Read on!
I constructed a form that would provide an output very similar to yours except I didn't include your third repeating section, RS_Kommunikation as it would be a repeat of the example provided below.
For people new to this post, we have two repeating sections. The first repeating section, I bind to a multiline SharePoint column that I've called "the xml". Inside that repeating section there are is another repeating section called RS_Handlingspunkter. This is what the raw XML looks like once the form data is saved to the "the xml" column:
<?xml version="1.0" encoding="utf-8"?><RepeaterData><Version /><Items><Item><Kvt_Valg type="System.String">1</Kvt_Valg><Kvt_Beskrivelse type="System.String">This is the main repeating section, row 1</Kvt_Beskrivelse><RS_Handlingspunkter type="System.String">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;RepeaterData&gt;&lt;Version /&gt;&lt;Items&gt;&lt;Item&gt;&lt;Handlingspunkt_Nr type=&quot;System.Int32&quot;&gt;11&lt;/Handlingspunkt_Nr&gt;&lt;Handlingspunkt_Titel type=&quot;System.String&quot;&gt;RS1 Item 1&lt;/Handlingspunkt_Titel&gt;&lt;Handlingspunkt_Beskrivelse type=&quot;System.String&quot;&gt;Apple&lt;/Handlingspunkt_Beskrivelse&gt;&lt;/Item&gt;&lt;Item&gt;&lt;Handlingspunkt_Nr type=&quot;System.Int32&quot;&gt;12&lt;/Handlingspunkt_Nr&gt;&lt;Handlingspunkt_Titel type=&quot;System.String&quot;&gt;RS1 Item 2&lt;/Handlingspunkt_Titel&gt;&lt;Handlingspunkt_Beskrivelse type=&quot;System.String&quot;&gt;Orange&lt;/Handlingspunkt_Beskrivelse&gt;&lt;/Item&gt;&lt;/Items&gt;&lt;/RepeaterData&gt;</RS_Handlingspunkter><Formal_fortaelling_indsats type="System.String"></Formal_fortaelling_indsats></Item><Item><Kvt_Valg type="System.String">2</Kvt_Valg><Kvt_Beskrivelse type="System.String">This is the main repeating section, row 2</Kvt_Beskrivelse><RS_Handlingspunkter type="System.String">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;RepeaterData&gt;&lt;Version /&gt;&lt;Items&gt;&lt;Item&gt;&lt;Handlingspunkt_Nr type=&quot;System.Int32&quot;&gt;21&lt;/Handlingspunkt_Nr&gt;&lt;Handlingspunkt_Titel type=&quot;System.String&quot;&gt;RS2 Item 1&lt;/Handlingspunkt_Titel&gt;&lt;Handlingspunkt_Beskrivelse type=&quot;System.String&quot;&gt;Pear&lt;/Handlingspunkt_Beskrivelse&gt;&lt;/Item&gt;&lt;/Items&gt;&lt;/RepeaterData&gt;</RS_Handlingspunkter><Formal_fortaelling_indsats type="System.String"></Formal_fortaelling_indsats></Item></Items></RepeaterData>
It's pretty ugly and it has lots of things making it hard to read such as &. Therefore the first thing we need to do in the workflow is decode the XML to get a "clean" version using the runtime function fn-XMLDecode inside the build string action:
I perform this twice as just to be safe. Don't ask me why but sometimes the function misses decoding some parts as I found out when I was testing the workflow. This is what the XML looks like after is has been cleaned up for easy reading:
<?xml version="1.0" encoding="utf-8"?>
<RepeaterData>
<Version/>
<Items>
<Item>
<Kvt_Valg type="System.String">1</Kvt_Valg>
<Kvt_Beskrivelse type="System.String">This is the main repeating section,row 1</Kvt_Beskrivelse>
<RS_Handlingspunkter type="System.String">
<?xml version="1.0" encoding="utf-8"?>
<RepeaterData>
<Version/>
<Items>
<Item>
<Handlingspunkt_Nr type="System.Int32">11</Handlingspunkt_Nr>
<Handlingspunkt_Titel type="System.String">RS1 Item 1</Handlingspunkt_Titel>
<Handlingspunkt_Beskrivelse type="System.String">Apple</Handlingspunkt_Beskrivelse>
</Item>
<Item>
<Handlingspunkt_Nr type="System.Int32">12</Handlingspunkt_Nr>
<Handlingspunkt_Titel type="System.String">RS1 Item 2</Handlingspunkt_Titel>
<Handlingspunkt_Beskrivelse type="System.String">Orange</Handlingspunkt_Beskrivelse>
</Item>
</Items>
</RepeaterData>
</RS_Handlingspunkter>
<Formal_fortaelling_indsats type="System.String"/>
</Item>
<Item>
<Kvt_Valg type="System.String">2</Kvt_Valg>
<Kvt_Beskrivelse type="System.String">This is the main repeating section,row 2</Kvt_Beskrivelse>
<RS_Handlingspunkter type="System.String">
<?xml version="1.0" encoding="utf-8"?>
<RepeaterData>
<Version/>
<Items>
<Item>
<Handlingspunkt_Nr type="System.Int32">21</Handlingspunkt_Nr>
<Handlingspunkt_Titel type="System.String">RS2 Item 1</Handlingspunkt_Titel>
<Handlingspunkt_Beskrivelse type="System.String">Pear</Handlingspunkt_Beskrivelse>
</Item>
</Items>
</RepeaterData>
</RS_Handlingspunkter>
<Formal_fortaelling_indsats type="System.String"/>
</Item>
</Items>
</RepeaterData>
It's still not perfect though as then we need to remove the three xml headers (the text <?xml version="1.0" encoding="utf-8"?>). These are included before each repeating section as you can see above. The Xpath engine gets confused by the multiple headers so we need to remove them. We'll use a regular expression to do this:
Now it's up to you how you want to deal with the data. For example if you wanted to save all the Handlingspunkt_Nr values into a single collection, you could use the Query XML action, use the expression
RepeaterData/Items/Item/RS_Handlingspunkter/RepeaterData/Items/Item/Handlingspunkt_Nr
and return the results as text.
The issue with this approach is you're combining all the results from both the main and the RS_Handlingspunkter repeating sections. I think you'd rather handle them on a row by row basis. Therefore my query XML action looks like this:
A couple of points to note here:
- I'm splitting by each row of the main repeating section hence me using the expression
RepeaterData/Items
- We need the results returned as XML because you'll want to parse the RS_Handlingspunkter repeating section separately and that is stored as XML. I have therefore chosen to return the results as Outer XML. Select Outer XML vs Inner XML because you want the opening and closing <Item> tags to create a well formed XML structure.
In this example we now have a collection called col Items with two items:
Item 1
<Item>
<Kvt_Valg type="System.String">1</Kvt_Valg>
<Kvt_Beskrivelse type="System.String">This is the main repeating section,row 1</Kvt_Beskrivelse>
<RS_Handlingspunkter type="System.String">
<RepeaterData>
<Version/>
<Items>
<Item>
<Handlingspunkt_Nr type="System.Int32">11</Handlingspunkt_Nr>
<Handlingspunkt_Titel type="System.String">RS1 Item 1</Handlingspunkt_Titel>
<Handlingspunkt_Beskrivelse type="System.String">Apple</Handlingspunkt_Beskrivelse>
</Item>
<Item>
<Handlingspunkt_Nr type="System.Int32">12</Handlingspunkt_Nr>
<Handlingspunkt_Titel type="System.String">RS1 Item 2</Handlingspunkt_Titel>
<Handlingspunkt_Beskrivelse type="System.String">Orange</Handlingspunkt_Beskrivelse>
</Item>
</Items>
</RepeaterData>
</RS_Handlingspunkter>
<Formal_fortaelling_indsats type="System.String"/>
</Item>
Item 2
<Item>
<Kvt_Valg type="System.String">2</Kvt_Valg>
<Kvt_Beskrivelse type="System.String">This is the main repeating section,row 2</Kvt_Beskrivelse>
<RS_Handlingspunkter type="System.String">
<RepeaterData>
<Version/>
<Items>
<Item>
<Handlingspunkt_Nr type="System.Int32">21</Handlingspunkt_Nr>
<Handlingspunkt_Titel type="System.String">RS2 Item 1</Handlingspunkt_Titel>
<Handlingspunkt_Beskrivelse type="System.String">Pear</Handlingspunkt_Beskrivelse>
</Item>
</Items>
</RepeaterData>
</RS_Handlingspunkter>
<Formal_fortaelling_indsats type="System.String"/>
</Item>
Now that each line has been saved to a collection entry, we are able to process the elements inside it. Use a for each loop to do this and save the item to a text variable:
For example, if we want to save all the Beskrivelses for the current row (which Google tells me means "Description" then use another Query XML using the expression
/Item/RS_Handlingspunkter/RepeaterData/Items/Item/Handlingspunkt_Beskrivelse
Note in this case how I have returned the results as Text as I don't want the XML tags around the data.
If you wanted to perform row by row manipulation of your RS_Handlingspunkter, then use Query XML with the expression /Item/RS_Handlingspunkter and save to a collection. Then you can use a for each loop to go through each element of the collection.
I've saved an export of the workflow here which also emails you some of the results - be sure to change your email address in the first set a variable action.
I hope that helps!
Cheers,
Chris