XML:
Code:
<ProductRevision id="id38" name="Item1" accessRefs="#id4" subType="ItemRev" masterRef="#id36" revision="A">
<UserData id="id39">
<UserValue value="2015-08-11T16:46:20" title="date_released"></UserValue>
</UserData>
</ProductRevision>
<ProductRevision id="id53" name="Item2" accessRefs="#id4" subType="ItemRev" masterRef="#id36" revision="A">
<UserData id="id39">
<UserValue value="2015-08-07T13:57:42" title="date_released"></UserValue>
</UserData>
</ProductRevision>
<ProductRevision id="id68" name="Item2" accessRefs="#id4" subType="ItemRev" masterRef="#id36" revision="A">
<UserData id="id39">
<UserValue value="2015-08-06T13:57:42" title="date_released"></UserValue>
</UserData>
</ProductRevision>
<Product id="id36" name="Item1" accessRefs="#id4" subType="Item" productId="1234">
<ApplicationRef version="g7cVc2GTznicWC" application="Teamcenter" label="g7cVc2GTznicWC"></ApplicationRef>
<AssociatedForm id="id50" role="IMAN_master_form" formRef="#id48"></AssociatedForm>
</Product>
<Product id="id51" name="Item2" accessRefs="#id4" subType="Item" productId="BXU004846">
<ApplicationRef version="gLZVMV_wznicWC" application="Teamcenter" label="gLZVMV_wznicWC"></ApplicationRef>
<AssociatedForm id="id65" role="IMAN_master_form" formRef="#id63"></AssociatedForm>
</Product>
<Product id="id66" name="Item3" accessRefs="#id4" subType="Item" productId="BXU004848">
<ApplicationRef version="weVVMpxFznicWC" application="Teamcenter" label="weVVMpxFznicWC"></ApplicationRef>
<AssociatedForm id="id80" role="IMAN_master_form" formRef="#id78"></AssociatedForm>
</Product>
<Form id="id48" name="1234" accessRefs="#id4" subType="Item Master" subClass="Item Master">
<UserData id="id49" type="FormAttributes">
<UserValue value="Class1" title="form_type"></UserValue>
</UserData>
</Form>
<Form id="id63" name="BXU004846" accessRefs="#id4" subType="Item Master" subClass="Item Master">
<UserData id="id64" type="FormAttributes">
<UserValue value="Class1" title="form_type"></UserValue>
</UserData>
</Form>
<Form id="id78" name="BXU004848" accessRefs="#id4" subType="Item Master" subClass="Item Master">
<UserData id="id79" type="FormAttributes">
<UserValue value="Class2" title="form_type"></UserValue>
</UserData>
</Form>
In the above xml, - ProductRevision node is related to Product Node through 'masterRef' value. 'masterRef' id on ProductRevision is equal to 'id' value on Product node. - Product node is related to Form node through 'formRef' value. 'formRef' id on Product/AssociatedForm/formRef is equal to 'id' value of Form node. In the above example i have to find the latest date_released of ProductRevision with form_type 'Class1' (form_type value is in Form node).
For example to find if first ProductRevision node is of type Class1: - Go to Product node (id36) and get its formRef id (id48) - product/AssociatedForm/formRef - Search Form xml nodes with id value as id48. In Form node, get form_type value and check if its 'Class1'. - If its Class1, to get date_released we have to go to corresponding ProductRevision node. - Search ProductRevision nodes with masterRef value as id36. Get date_released form ProductRevision node.
I was able to write logic to traverse the nodes and check form_type value and get date_released, but stuck on how to get latest date_released from these nodes. Requirement is to get latest date_released of ProductRevision's with form_type as 'Class1'.