Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8768193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:00:42+00:00 2026-06-13T17:00:42+00:00

Using java, I’m trying to find the most recent highest entry number. This entry

  • 0

Using java, I’m trying to find the most recent highest entry number. This entry needs to specify a specific type. From there it needs to pull the value.

Here’s what the xml looks like

<XmlFile>
   <data_item>
        <data_report>
            <type>My_Type</type>
            <entry_number>12</entry_number>                
            <value>1234</value>
        </data_report>
        <data_report>
            <type>My_Type</type>
            <entry_number>9</entry_number>                
            <value>11234</value>
        </data_report>
   </data_item>
   <data_item>
      <data_report>
             <type>My_Type</type>
            <entry_number>17</entry_number>                
            <value>112354</value>
      </data_report>
      <data_report>
             <type>Not_My_Type</type>
            <entry_number>122</entry_number>                
            <value>11234</value>
      </data_report>
   </data_item>
</XmlFile>

So the takeaways are the data I need needs to be of “My_Type” it can be in ANY data_item, but it needs to find the maximum interval out of all items of my_type, the pull the value only.

I have tried doing this with Xpath, but I couldn’t quite get it to work. In this case the third data report (in the second data item) would be the one I’m after since it has the highest entry number while being “My Type” so I would want the program to grab the number 112354 for me.

Is there some way to do this using Xpath? The file that I’m trying to get this to work on is MUCH larger than this, but Xpath seems like the easiest option, I’m not opposed to DOM or SAX if those are better suited.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:00:44+00:00Added an answer on June 13, 2026 at 5:00 pm

    The max() function is not available in XPath 1.0.

    A pure XPath expression that produces the wanted (of the first if there are more than one nodes with the wanted maximum property) value, is:

       string(
          /*/*/*[type='My_Type'
               and
                 not(/*/*/*[type='My_Type']/entry_number > entry_number)
                ][1]/value
              )
    

    XSLT – based verification:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
    
     <xsl:template match="/">
         <xsl:copy-of select=
         "string(
          /*/*/*[type='My_Type'
               and
                 not(/*/*/*[type='My_Type']/entry_number > entry_number)][1]/value
              )"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the provided XML document:

    <XmlFile>
        <data_item>
            <data_report>
                <type>My_Type</type>
                <entry_number>12</entry_number>
                <value>1234</value>
            </data_report>
            <data_report>
                <type>My_Type</type>
                <entry_number>9</entry_number>
                <value>11234</value>
            </data_report>
        </data_item>
        <data_item>
            <data_report>
                <type>My_Type</type>
                <entry_number>17</entry_number>
                <value>112354</value>
            </data_report>
            <data_report>
                <type>Not_My_Type</type>
                <entry_number>122</entry_number>
                <value>11234</value>
            </data_report>
        </data_item>
    </XmlFile>
    

    the XPath expression is evaluated and the result of this evaluation is copied to the output:

    112354
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using java I am trying to develop a method using recursion to analyze a
Using Java sockets, I made a simple server. This works because it sends data
When using java.util.logging, the log level for a specific class (i.e. for a child
Using java.util.logging.Logger to output some log to the console just like this: public static
Using Java over Windows Vista, I'm trying to create a kind of a monitor
Using java.util.regex.Pattern.compile() you can specify a pattern as parameter. But how can you specify
Using Java is it possible to capture the speaker output? This output is not
Using Java, how do I check if a specific TCP/IP port is open and
When using Java LinkedList how do you find out the element's next or previous
Using Java: I didn't want to waste peoples time and post this here, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.