How to extract value from element xml if other element has a especific value

Maybe the following will work or provide complete XML data for cross checks

xmlDes.Root.Descendants(dicNamespaces(“n4”) + "AdditionalProperty").Where(Function (x) x.Element(dicNamespaces("n2") + "Name").Value.Trim.Equals("@@FamiliaProducto")).Select(Function (x) x.Element(dicNamespaces("n2") + "Value").Value).FirstOrDefault()

But with Query Syntax we can organize it more readable used within an assign activity

strValue =
(From xe In xmlDes.Root.Descendants(dicNamespaces("n4") + "AdditionalProperty")
Where xe.Element(dicNamespaces("n2") + "Name").Value.Trim.Equals("@@FamiliaProducto")
Select v=  xe.Element(dicNamespaces("n2") + "Value").Value).FirstOrDefault()

Also good to know is to using XPath with a Namespacemanager, when xPath is known and filter predicates can be managed

1 Like