Forum Discussion

MRutten's avatar
Occasional Contributor
2 years ago

Extracting value from XML element with multiple attributes using Groovy



I want to extract the base64 encoded value of the XML element below to decode it and store the file locally.



<ZKN:inhoud StUF:bestandsnaam="mail1684835925155.txt" xmime:contentType="text/plain" xmlns:xmime="">VmFuOm5vcmVwbHkua.........gT2lyc2Nob3QK</ZKN:inhoud>



I am extracting the element using 

def docInhoudGroup = context.expand( '${geefZaakdocumentLezen_Lv01 - dundee - 623#Response#declare namespace ZKN=\'\'; //ZKN:edcLa01[1]/ZKN:antwoord[1]/ZKN:object[1]/ZKN:inhoud[1]}' )


This results in object docInhoudGroup: 




And I am not successful in assigning the base64 encoded value to a new variable for further processing.


I am able to extract the value of subelement 'StUF:bestandsnaam' of 'ZKN:inhoud' but as stated not the value of element 'ZKN:inhoud':

def docFileName = context.expand( '${geefZaakdocumentLezen_Lv01 - dundee - 623#Response#declare namespace StUF=\'\'; declare namespace ZKN=\'\'; //ZKN:edcLa01[1]/ZKN:antwoord[1]/ZKN:object[1]/ZKN:inhoud[1]/@StUF:bestandsnaam}' )


Hope someone can give me a hint.


Kind regards



No RepliesBe the first to reply