Xml DataSet Child Parent Element Same Name Table Id



I am trying to iterate through a DataSet created by reading in an XML response using DataSet.ReadXML() method. The following is an example of the XML response used to create the DataSet:



<Patterns>
<Pattern>
<PatternElements>
<PatternElement Number="1">
<ElementCode>
<ElementCode>
<Segments>
<Segment Name="One"/>
</Segments>
</ElementCode>
</ElementCode>
</PatternElement>
<PatternElement Number="2">
<ElementCode>
<ElementCode>
<Segments>
<Segment Name="Two"/>
</Segments>
</ElementCode>
</ElementCode>
</PatternElement>
<PatternElement Number="3">
<ElementCode>
<ElementCode>
<Segments>
<Segment Name="Three"/>
</Segments>
</ElementCode>
</ElementCode>
</PatternElement>
</PatternElements>
</Pattern>
</Patterns>


I am trying to use the table's Id number to ensure I am grabbing the segment which corresponds to the pattern element using "TableName_Id". The problem I have is the tag has a child with the same name. If there were just one tag I would simply verify the PatternElement_Id in the ElementCode table rows but in this case the Parent and Child Xml Elements have the same name. How do I verify which PatternElement the ElementCode belongs to in this senario? Thanks for the help here, I really appreciate it :)


No comments:

Post a Comment