Need help with complicated? XML query
-
<Hi, I'm new to LINQ and having some problems writing a query that looks at 2 levels of an XML document. This is my XML structure:
<TransitionList>
<ActionTransition action="Advance">
<Transition>
<OrigStatus>
<VersionStatus>Added</VersionStatus>
<PendingDbAction>Add</PendingDbAction>
<IsDraft>No</IsDraft>
</OrigStatus>
<FinalStatus>
<VersionStatus>Added</VersionStatus>
<PendingDbAction>None</PendingDbAction>
<IsDraft>No</IsDraft>
</FinalStatus>
</Transition>There are many <ActionTransition> with different action attribute, and each contains many <transitions>. I need to find <FinalStatus> by 1. The value of attribute action in the parent '<ActionTransition>'. 2. The value of the 3 values in the '<OrigStatus>' element. I haven't got near to anything that might do this. Is this possible? Thanks.
-
<Hi, I'm new to LINQ and having some problems writing a query that looks at 2 levels of an XML document. This is my XML structure:
<TransitionList>
<ActionTransition action="Advance">
<Transition>
<OrigStatus>
<VersionStatus>Added</VersionStatus>
<PendingDbAction>Add</PendingDbAction>
<IsDraft>No</IsDraft>
</OrigStatus>
<FinalStatus>
<VersionStatus>Added</VersionStatus>
<PendingDbAction>None</PendingDbAction>
<IsDraft>No</IsDraft>
</FinalStatus>
</Transition>There are many <ActionTransition> with different action attribute, and each contains many <transitions>. I need to find <FinalStatus> by 1. The value of attribute action in the parent '<ActionTransition>'. 2. The value of the 3 values in the '<OrigStatus>' element. I haven't got near to anything that might do this. Is this possible? Thanks.
The xml you present is very flat xml. What I'd expect to see is something like this for running a linq query against:
<Transitions>
<ActionTransition action="Advance">
....
</ActionTransition>
<ActionTransition action="Initial">
...
<ActionTransition action="Something">
</Transitions>Your ActionTransition object would then be accessible via it's depths ActionTransition.Transition.FinalStatus.{finalStatusProperty} I'm not 100% certain but I believe you need a recurring entity in your xml to make linq to xml useful.