I am trying to put child values ββfrom XML into a dictionary collection using LINQ. I did this with lists and user collections that follow the same structure as XML, but I cannot find specific values. If I know parentName, childName and subChildName, I want to find subChildProperty1.value and subChildProperty2.value without iterating over the entire collection and each of the following subcategories, as I should do with lists. This may not be the best implementation, and I'm open to suggestions, but still would like to figure out how to do it. Then it will allow me to have a dictionary element:
key = "parentNameValue1.childNameValue1.subchildNameValue1.subChildProperty1" value = 0
and I could just concatenate the strings to form a specific key and search on that key to return the value.
XML:
<root> <parent> <parentName>parentNameValue1</parentName> <child> <childName>childNameValue1</childName> <subchild> <subchildName>subchildNameValue1</subchildName> <subChildProperty1>0</subChildProperty1> <subChildProperty2>5</subChildProperty2> </subchild> <subchild> <subchildName>subchildNameValue2</subchildName> <subChildProperty1>0</subChildProperty1> <subChildProperty2>10</subChildProperty2> </subchild> </child> </parent> <root>
This question is somewhat similar to this question here , but I could not get the code working in VB for my application.
I'm new to SO (and VB), so I apologize if my etiquette is wrong.
source share