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

  • Home
  • SEARCH
  • 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 833789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:34:23+00:00 2026-05-15T04:34:23+00:00

I wanna read feed entries and I’m just stuck now. Take this for example

  • 0

I wanna read feed entries and I’m just stuck now. Take this for example : https://stackoverflow.com/feeds/question/2084883 lets say I wanna read all the summary node value inside each entry node in document. How do I do that? I’ve changed many variations of code this one is closest to what I want to achieve I think :

Element entryPoint = document.getRootElement();
  Element elem;
  for(Iterator iter = entryPoint.elements().iterator(); iter.hasNext();){
   elem = (Element)iter.next();
                    System.out.println(elem.getName());
  }

It goes trough all nodes in xml file and writes their name. Now what I wanted to do next is

if(elem.getName().equals("entry"))

to get only the entry nodes, how do I get elements of the entry nodes, and how to get let say summary and its value? tnx

Question: how to get values of summary nodes from this link

  • 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-05-15T04:34:24+00:00Added an answer on May 15, 2026 at 4:34 am

    Here’s how you’d do it using vanilla Java:

    //read the XML into a DOM
    StreamSource source = new StreamSource(new StringReader("<theXml></theXml>"));
    DOMResult result = new DOMResult();
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.transform(source, result);
    Node root = result.getNode();
    
    //make XPath object aware of namespaces
    XPath xpath = XPathFactory.newInstance().newXPath();
    xpath.setNamespaceContext(new NamespaceContext(){
        @Override
        public String getNamespaceURI(String prefix) {
            if ("atom".equals(prefix)){
                return "http://www.w3.org/2005/Atom";
            }
            return null;
        }
    
        @Override
        public String getPrefix(String namespaceURI) {
            return null;
        }
    
        @Override
        public Iterator getPrefixes(String namespaceURI) {
            return null;
        }
    });
    
    //get all summaries
    NodeList summaries = (NodeList) xpath.evaluate("/atom:feed/atom:entry/atom:summary", root, XPathConstants.NODESET);
    for (int i = 0; i < summaries.getLength(); ++i) {
        Node summary = summaries.item(i);
    
        //print out all the attributes
        for (int j = 0; j < summary.getAttributes().getLength(); ++j) {
            Node attr = summary.getAttributes().item(j);
            System.out.println(attr.getNodeName() + "=" + attr.getNodeValue());
        }
    
        //print text content
        System.out.println(summaries.item(i).getTextContent());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i wanna read all the lines from a text so am doing this int
I have a file and I don't wanna take a copy from this file.
I just wanna learn how to read Iframe content in onLoad event of iframe
I wanna read out a server status webpage every x seconds. Site is: http://www.ffxiv-status.com/
in this i write the cookie value in controller file. i wanna read that
This is basically what I am trying to do. I wanna take a File
I wanna verify a digitally signed xml against its schema definition while this schema
Please help me!I dont know why i cant solve this simple problem. I wanna
I wanna know how it is possible to read a file in binary format.
I read how to do it with a service, but i wanna know if

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.