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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:00:33+00:00 2026-06-09T23:00:33+00:00

This piece of Java code prints the title, link and publication date of every

  • 0

This piece of Java code prints the title, link and publication date of every item from the NYT’s World RSS. But for the NYT’s Science RSS it doesn’t print the link field. What is happening here?

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();

Document doc = builder.parse( direccion );
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
XPathExpression expr = xpath.compile("/rss/channel/item");
NodeList nl = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
for (int i = 0; i < nl.getLength(); i++) {
    Node node = nl.item(i);

    Node nodoTitulo = (Node) xpath.evaluate("title", node, XPathConstants.NODE);
    System.out.println(nodoTitulo.getTextContent());

    Node nodoLink = (Node) xpath.evaluate("link", node, XPathConstants.NODE);
    System.out.println(nodoLink.getTextContent());

    Node nodoFecha = (Node) xpath.evaluate("pubDate", node, XPathConstants.NODE);
    System.out.println(nodoFecha.getTextContent());
    System.out.println();
}
  • 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-09T23:00:35+00:00Added an answer on June 9, 2026 at 11:00 pm

    It’s a namespace issue.

    In the science RSS, you have

    <atom:link href="http://www.nytimes.com/2012/08/19/business/new-wave-of-adept-robots-is-changing-global-industry.html?partner=rss&amp;emc=rss" rel="standout"/>
    <title>The iEconomy: New Wave of Deft Robots Is Changing Global Industry</title>
    <link>http://feeds.nytimes.com/click.phdo?i=5861b5e3f6b66da6ca12beab1e5d8729</link>
    

    In the world RSS, you have

    <title>Syrian Rebels Claim to Have Brought Down a Jet</title>
    <link>http://feeds.nytimes.com/click.phdo?i=314bd32f9d6141a500e76e3076c489c9</link>
    .
    .
    .
    <atom:link rel="standout" href="http://www.nytimes.com/2012/08/14/world/middleeast/syrian-rebels-claim-to-have-brought-down-a-jet.html?partner=rss&amp;emc=rss"/>
    

    Your code is picking up the <atmoic:link> node first.

    Add:

    factory.setNamespaceAware(true);
    

    After you create the factory and before you create the builder and you should now be getting the link

    title = The iEconomy: New Wave of Deft Robots Is Changing Global Industry
    link = http://feeds.nytimes.com/click.phdo?i=5861b5e3f6b66da6ca12beab1e5d8729
    pubDate = Sun, 19 Aug 2012 21:26:33 GMT
    

    And if you’re really interested, you can have a read of this for some more info

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

Sidebar

Related Questions

I am using iTextSharp in VB.net. I have this piece of code from java
Can someone show me a piece of java code that parses this date: 2009-08-05
I am trying to translate this piece of code from Java to C# and
Context I have this piece of Java Code btn.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent
I have a piece of code VERY similar to this one http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailFetching I the
This piece of code is from Adobe docs : package { import flash.display.Loader; import
I have writed this piece of code in java: String[] tokens = strLine.split(delims); SimpleOrderRequest
I've got this piece of Java code with embedded Rhino (irrelevant bits omitted): Context
Why this piece of java code looks for a file in my Home directory?
I have a piece of java code which reads strings from a file and

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.