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 8208019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:11:48+00:00 2026-06-07T09:11:48+00:00

So I have a project where I need to pull an xml file that

  • 0

So I have a project where I need to pull an xml file that is updated every 5 minutes. However I’m designing my program to pull this file every time it updates.

The data structure of the xml file is like this…

<m:REPORT_DATA>
    <m:DATA_ITEM>ENC</m:DATA_ITEM>
    <m:RESOURCE_NAME>DLAP</m:RESOURCE_NAME>
    <m:OPR_DATE>2012-06-02</m:OPR_DATE>
    <m:INTERVAL_NUM>1</m:INTERVAL_NUM>
    <m:VALUE>16.77734</m:VALUE>
</m:REPORT_DATA>
<m:REPORT_DATA>
    <m:DATA_ITEM>ENC</m:DATA_ITEM>
    <m:RESOURCE_NAME>DLAP</m:RESOURCE_NAME>
    <m:DATE>2012-06-02</m:OPR_DATE>
    <m:INTERVAL_NUM>2</m:INTERVAL_NUM>
    <m:VALUE>16.77739</m:VALUE>
</m:REPORT_DATA>
....

Assuming that I pull it for the 200th time that day, how would I grab just the last value

"<m:VALUE>16.77739</m:VALUE>"

And get that value for my database?

I’m torn about using Sax, Xpath, or DOM. Some help would be amazing.

  • 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-07T09:11:50+00:00Added an answer on June 7, 2026 at 9:11 am

    If you had a root, lets say <m:REPORTS>, finding the last VALUE using XPath would be rather simple:

        XPathFactory f = XPathFactory.newInstance() ;
        XPath x = f.newXPath() ;
        try {
            InputSource source = new InputSource(new FileInputStream("logfile.xml")) ;
            XPathExpression expr = x.compile("//REPORT_DATA[DATA_ITEM='ENC'][last()]/VALUE/text()") ;
            String s = expr.evaluate(source) ;
            System.out.println("Last value: " + s ) ;
        }
        catch(Throwable t) {
            System.err.println("Error: " + t) ;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following xml file that I need to read into my C#
I have a project where I need to pull in a lot of records
I have a project that is stored in a Subversion repository. In this repository,
I need to implement a project that will consume XML Web Service from other
I have a project where I need to create a desktop app that acts
I have created this function GetSubName that I need to return the name that
I have some external configuration (XML files) that are installed in Maven. I need
The Junits I have in my project need to load property files from the
I have a project where I need to monitor changes in a 3rd party
I have a project where I need to compare multi-chapter documents to a second

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.