I am having trouble finding logic to count a number of items in an XML.
This is a sample of an XML. What I need to know is how many “det nItem” are in XML. Note: This amount is variable. I tried using Xpath, Get XML Nodes, .Element. Well, I don’t know if I’m using it the wrong way, but none of them worked for what I need
Can someone help me
From the output that components create you can do your thing!
This might be helpful to you Please see the link for your reference.
You can get it using Deserialize XML Activity in UiPath.Web.Activities package.
The following steps shows how to get the number of “<det nitem=” under root element.
Read your xml as string, and parse it by Deserialize XML activity as xDocument (
Get root element (
xRoot=xDoc.Root) and its namespace (
Get descendants which name is “det”.
elementsDet = xRoot.Descendants(xNS+"det")
Get number of det element which has nItem attribute.
count = xElementsDet.Count(function(x) x.Attributes("nItem").Count>0)
I’ll attach the following sample.
Sample20191109.zip (15.5 KB)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.