Reading XML Attribute out of Uipath Xaml file

Hi All.

I’m about to create a validation robot that can perform a sanity check of Uipath Automation projects.

My current goal is to check Invokes in order to ensure that .xaml files are used if they are included in the project folders. But I’m getting stuck in finding any generic way of picking up All Invokes per file including attribute WorkflowFileName “Name”/“Value”

This is the syntax around how xaml file around Inwokeworkflowfile are structured.

<ui:InvokeWorkflowFile ContinueOnError=“{x:Null}” DisplayName=“Invoke GetTransactionData workflow” sap2010:WorkflowViewState.IdRef=“InvokeWorkflowFile_4” UnSafe=“False” WorkflowFileName=“calculate client security hash\ReFrameWork-master\Framework\GetTransactionData.xaml”>
ui:InvokeWorkflowFile.Arguments
<scg:Dictionary x:TypeArguments=“x:String, Argument” />
</ui:InvokeWorkflowFile.Arguments>
</ui:InvokeWorkflowFile>

My current approach is to pick it up using invoke Code activity and the following code can compile but I’m not getting any information out of it.

Dim doc As New XmlDocument
doc.Load(“C:.…\Uipath_REFrameWork_UiDemo\Main.xaml”)
Dim ReturnValue As New List(Of String)
Dim Arr As String()
Dim Str As String
Dim i As Integer = 0
For Each node As XmlNode In doc.SelectNodes(“//WorkflowFileName”)
ReturnValue.Add(node.attributes(“WorkflowFileName”).Value)
ReDim Preserve arr(i)
arr(i) = ReturnValue.ToString
Str = ReturnValue.ToString
console.WriteLine(str)
console.WriteLine(i)
i += 1
Next
Out_Argument = Arr
String_out = str

I’ve previosly also tried the decerielize approach and tried xpath expressions etc but that was not sucessfull due to the Ui. start of the element ui:InvokeWorkflowFile

Anyone who succesfully have automated around the xaml files and have something to share?

Best regards
/Viktor

I did something similar some time ago and I’m attaching a sample: CheckInvokes.xaml (13.6 KB)
I used an Xpath expression to find the elements whose names are ui:InvokeWorkflowFile: "//ui:InvokeWorkflowFile".

Did you use a namespace manager when calling SelectNodes?

PS: There’s a little bug in the attached sample because since the main file isn’t invoked by an Invoke Workflow File activity, it is counted as an unused workflow. But this can be corrected by checking the main field in the project.json for the main file’s name and removing it from the list of files to be checked.

5 Likes

I don’t suppose you have a solution for dynamically invoked workflows? I’ve been struggling with that for some time already and gave up.
(I know it’s naive to ask about that, but hey - surprises happen sometimes :slight_smile: )

What do you mean by dynamically invoked workflows?

Invokes where workflow names are known only on runtime, i.e. built from varables/assets.

Ah, I see. Yes, I haven’t considered those cases.
But it’s an interesting point… I’ll think a bit about it and update here if any idea comes up :+1:

Thanks,
It solved my problems, I notice there are a number of different ways to do it but your solution was as good as any. :+1:

Hi,

I am also woring on the same kind of task. I am able to read the arguments, invoke workflow files but i am not able to read the variables in xaml file.
can any one help on this…

thanks in advance…