How to extract multiples records in same XML file (with namespaces)?

Hi everybody,

I have a xml file, on this file i need to get multiples Description values. My problem is that tag is the same for the all values so when i invoke the method always get the first value. Example, Take a look at picture for more details.

Could you help me please.

Thanks in advance.


The following steps might help you.

  1. Get all cac: InvoiceLine Elements as IEnumerable using Descendants method.

  2. Iterate above collection and get cbcID Element and cbc:Description in each cac:InvoiceLine Element (using Descendants method etc).

  3. If nescessary, it might be good idea to use Dictionary to link ID and Description

If you can share your whole xml file,I might be able to comment more details.


1 Like

For working with XML having namespaces have a Look Here

The steps given from @Yoichi are covering the Main actions for your scenario

ADDED: Link to some analysis techniques for XML Namespaces:

Hi @Yoichi :slight_smile: Thanks for answer me,

My .xml file attach here.

Data.xml (803 Bytes)

i already get the first ID value (i attach my project here)

Main.xaml (14.0 KB)

but i need to get all descriptions like the previous imagen though a loop (for each activity, for example) and for that, my condition or key is “cbc: ID”. For example, if exist three ID values (ID: 1, ID: 2 and ID: 3) i need to get the three description values from “cbc: Description”.

Thanks for advance.

Hi @ppr
Your response was very useful, it works!

Thanks so much.

The “Function (e)” is new for me. When can i use that? how it works? Do you have a link about that?


Its about LINQ
Where Method got a defined Function/Lambda that is defining what to do. The Syntax Function (e) is defining this and e is a variable name for this defined function representing the item that is processed in the function.
To get more information about this topic have a look here: LINQ Method Syntax

ADDED: Link to LINQ Learning catologue

1 Like

Thanks @ppr.

We keep us in touch :+1:

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