How to save data from xml to a dictionary

Hello! i have to convert data from an xml file that is looking like this.

Geonomenclature_2022.xml (35.2 KB)
To a dictionary of this form:
new Dictionary(Of String(), String()){{“AD”, “Andorra”}, {“AF”, “Afganistan”}}
The should be key and the value.
How i can do that without foreach?
Thank you!

we need to handle the XML Namespace:


Then we can do:

xDoc.Root.Descendants(xnsDefault + "Item").ToDictionary(Function (x) x.Element(xnsDefault + "Code").Value, Function (x) x.Element(xnsDefault + "NameEn").Value)

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