Yur
(Yur)
June 11, 2021, 1:47pm
1
Hello,
I need help to extract, for example, the yellow coloured field from XML Namespace:
I am trying this method: xmlDocument.Element(str_Url+“decisiondocument”).Element(str_Lab1+“block”).Element(str_lab2+“subdictionary”).Element(str_lab3+“v”).Attribute(“PasoAPaso”).Value
I am trying different access methods but I can’t find a way to extract the field, can someone please help me?
ppr
(Peter Preuss)
June 11, 2021, 3:59pm
2
@Yur
as the element of interest is very on top you can analyse access options by following
set a breakpoint after XML serializing
debug and get the bot paused
open immediate panel and type in: YourXDocVar.Root.Descendants()(0).Name
increase the index 0,1,2,3… till you will get the element of interest
from the returned name you can derive the constraints for access
{xxx}elementname - xxx represents the value needed for the XNamespace
Kindly note: Element(str_Lab1+“block”) will have no return as name is a common attribute but not defining a namespace
use in last Descendants(id)
Yur
(Yur)
June 13, 2021, 8:21am
4
Hello!
Could you show me an example, please.
Yur
(Yur)
June 13, 2021, 8:28am
5
Hello, Peter,
Thank you very much for your reply.
I have applied your instruction but it is only useful in case I want to access the information through its index…
Do you know how I could access each field through the Key of the label?
For example, do you know how I could access the record number 28 that I colour in the attached image?
Thank you.
ppr
(Peter Preuss)
June 13, 2021, 11:39am
6
@Yur
the access by index was only to find out the element names and its details (using namespace or not, which value has the namespace part).
Maybe you can share with us results from
YourXDocVar.Root.Descendants()(X).Name with X=0,1,2,3
Based on this we can help you to loop over the different subdictionary elements with the help of Descendants method within a dynamic approach.
Maybe you can share also sample xml with us.
Yur
(Yur)
June 13, 2021, 6:49pm
7
Hello,
Thank you very much for your reply.
I attach an image showing how using the statement YourXDocVar.Root.Descendants()(X).Name with X=0,1,2,3…we access the existing tag at each level, but it does not allow us to extract the value of the required tag:
M2__20210611_100808.xml (25.6 KB)
I also attach the XML file in case you would like to do some testing, Peter.
Thank you very much.
ppr
(Peter Preuss)
June 13, 2021, 8:10pm
8
@Yur
with test by index on the names we do see, that the element name without any namespace info can be used.
Have a look on following flow just iterating dynamily over all elements from all subdictionarties and its contained v elements.
item = xDoc.Root.Descendants(“subdictionary”).toList
for each settings:
first log message:
String.Format("Process subdict: {0} Name: {1}", idx1, item.Attribute("name").value)
e = item.Descendants().toList
second log message:
String.Format("Element: {0} with id: {1} has value: {2}", e.Name.toString, e.Attribute("id").Value, e.Value)
we do not know what in details is planned for extracting values. But also have a look on following method:
find starter help here:
XMLStarter.xaml (7.9 KB)
1 Like
Yur
(Yur)
June 15, 2021, 3:43pm
9
Hey @ppr ,
Thank you very much for your help in solving this problem. Without a doubt the xaml you provided helped me a lot to understand the solution you were proposing.
Thank you very much again
system
(system)
Closed
June 18, 2021, 3:44pm
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.