XML: how to reach different fields with same name on the same level of hierarchy


After deserializing the XML-document, I’m trying to update fields with new values. But, some of the fields (placed in the same level in hierarchy) are having the same nametag.

        <Code v="01" />
        <Text v="Test01" />
        <Code v="02" />
        <Text v="Test02" /> 
        <Code v="03" />
        <Text v="Test03" />

I’m using XML_deserialized.Element(“Doc”).Element(“Description”).Element(“Text”).Attribute(“v”).Value to access the first instance of text(where code=01), but how to I tailor my syntax to reach the second and third instance (where code=02 and code=03)?

Edit: the code values are static, and used to identify the different fields. 01 e.x. is the identifier for name, so the text field related to code=01 should be updated with a name value. Code=02 is for adress and Code=03 is for telephone.

Please help me! :slight_smile:

give a try on:

for worlking second description:

other options are

  • doing filtering with LINQ
  • Access with XPATH

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