Strangely structured xml code finding last value of a certain type using java

Posted by Damien.Bell on Stack Overflow See other posts from Stack Overflow or by Damien.Bell
Published on 2012-10-24T22:51:06Z Indexed on 2012/10/24 23:00 UTC
Read the original article Hit count: 326

Filed under:
|
|
|
|

Thus the structure is something like this:

OasisReport>MessagePayload>RTO>Report_Item>Report_Data

Under report data it's broken into categories:

>>Zone
>>Type
>>Value
>>Interval

What I need to do is:

Get the value if the type is equal to 'myType' and the interval value is the LARGEST.

So an example of the xml might be (under report_data):

OasisReport
 MessagePayload
  RTO
   REPORT_ITEM
    REPORT_DATA
      <zone>myZone1</zone> -- This should be the same in all reports since I only get them for 1 zone
      <type>myType</type> --This can change from line to line
      <value>12345</value>--This changes every interval
      <Interval>122</Interval> -- This is essentially how many 5 minute intervals have taken place since the beginning of a day, finding the "max" lets me know it's the newest data.

Thereby I want to find stuff of "MyType" for the "max" interval and pull the Value (into a string, or a double, if not I can convert from string.

Can someone help me with this task?

Thanks!

Note: I've used Xpath to handle things like this in the past, but it seems outlandish for this... as it's SO complex (since not all the reports live in the same report_item, and not all the types are the same in each report)

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml