How to read XML nodes

Hi there,

This is my xml script. I want to ask is there any ways to read in elements flagpfv based on pfSeqNo.
For example, I want the output of ADMINSTRATION based on the pfSeqNo 3.

I appreciate any reply from you. Thanks and best regards.

1 Like

Hi,

The following steps might help you.
1.Get pf element. (pf as XElement)

2.Get all item Elements as IEnumerable using Descendants method.
itemList = pf.Descendants("item")

3.Iterate above collection and get pfsrqNo Element and pfv Element each item Element (using Descendants method etc).
for each item in itemList
pfsqNo = item.Descendants("pfsrqNo").First
pfv= item.Descendants("pfv").First

4.If necessary,use Dictionary to link pfseqno and pfv.

dictionary(pfseqno.Value.toString.trim) = pfv.Value.toString

Then you can get the value as dictionary(“3”)

Regards,

Hi @Yoichi
I have tried the workflow using your steps, but there was errors occurred on my workflow.
Can you kindly check for me please?
Attaching xaml file below.
test.xaml (7.0 KB)

1 Like

Hi @Yoichi

Try this

How to read XML

Thanks
Ashwin.S

Hi @AshwinS2
I got to run out the results, but the problem is my xml file having similar nodes, that’s why I can’t extract it using their nodes. So how am I going to run out all data based on their pfSeqNo?

Hi @yushinchan

Use deserialize xml activity and pass the values in add to dictionary activity and check the value

Thanks
Ashwin.S

Hi @AshwinS2
Can you kindly check with my workflow?
test.xaml (7.5 KB)
I do appreciate it so much. Thanks and best regards.

Hi,

You need to create and initialize Dictionary instance.

I’ll attach modified xaml file as the following.

test.xaml (8.8 KB)

Regards,

Hi @Yoichi
Thanks for your workflow. I have tried your workflow and I wonder what’s this error? And how am I going to modify it?

Hi,

Can you check if pfsqNo and pfv have value using breakpoint in Debug mode?
Or can you share your xml file, because I cannot check if it works good? (It’s no problem if they are dummy data.)

Regards,

Hi @Yoichi
I can’t share it the xml file, but I do paste my xml script in .txt format here. Is it okay?
TEST.txt (908 Bytes)

Sorry for inconvenience caused.

Hi,

Thank you for sharing it and sorry for my mistake.

I forgot to create instance of the dictionary.
Please add Default value as New Dictionary(Of String, String) at dic in Variable Panel, like the following image.

Regards,

Hi @Yoichi
It’s work :') But is it possible if I want to extract only some item from all these items?
For example, I only want to extract Company Name, Occupation and Consent for Direct Marketing?

Thanks and best regards.

Hi,

You can do it using If activity if my understanding is right.
Hope the following might help you.

test.xaml (11.5 KB)

Regards,

2 Likes

Hi @Yoichi
Do help me a lot. Thanks so much :')

Can help me look through another questions?

Thanks and best regards.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.