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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:46:40+00:00 2026-05-30T11:46:40+00:00

I am trying to read an external rss feed using a xAgent, I seem

  • 0

I am trying to read an external rss feed using a xAgent, I seem to be gettig xml errors like the once below, I suspect it is because I read the xml line by line using the bufferedReader

I get errors like these

  • “error on line 1 at column 32: Extra content at the end of the document”
  • “error on line 1 at column 6561: Opening and ending tag mismatch: item line 0 and channel”

here is what I have tried

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false">
<xp:this.afterRenderResponse>
<![CDATA[#{javascript:

var u:java.net.URL  = new java.net.URL("http://www.xpages.info/XPagesHome.nsf/NewsFeed.xsp?format=rss");
var br:BufferedReader= new java.io.BufferedReader(new java.io.InputStreamReader(u.openStream()));
var tmp="";
while(br.readLine() != null){
    tmp+= br.readLine();
}

var externalContext = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = externalContext.getResponse();
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
writer.write(tmp);
writer.endDocument();
}]]>

</xp:this.afterRenderResponse>
</xp:view>
  • 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-30T11:46:41+00:00Added an answer on May 30, 2026 at 11:46 am

    You are using the XAgent as a proxy. In case you want to actually do more I suggest to use better classes. The minimum would be the HTTP client (handles all the connection nastiness) or if your source is ATOM, the Apache Abdera classes (which under the hood use the HTTP client).

    The issue you have: the stream contains also the header information, so your XML doesn’t start with <. Using the HTTP client you can avoid that.

    A little bit like this:

    public String getURL(String url) {
    
        System.out.println("Fetching " + url);
    
        if (this.httpClient == null) {
            this.initializeHTTPSession();
        }
    
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        HttpGet get = new HttpGet(url);
    
        String result = null;
    
        try {
            result = this.httpClient.execute(get, responseHandler);
        } catch (HttpResponseException e) {
            System.out.println(e.getMessage());
            return null;
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnknownHostException e) {
            result = "The host is invalid: " + url;
        } catch (IOException e) {
            e.printStackTrace();
        }
    
        return result;
    }
    

    Full source code here: http://www.wissel.net/blog/downloads/SHWL-8BQPJD/$File/HTTPReader.java

    You might want to use something else than a String for the response handler.

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

Sidebar

Related Questions

Trying to read an RSS and select information using Linq but can't seem to
I'm trying to read the contents of an external xml feed. When I view
I'm trying to read an Excel (xlsx) file using the code shown below. I
I am trying to read some XML received from an external interface over a
I'm currently trying to read in an XML file, make some minor changes (alter
I'm trying to read through the documentation on Berkeley DB XML , and I
I'm trying to find a way to read a privateKey created using OpenSSL PKCS#8
I'm trying to read use fread to read in values from an external file
I'm trying to parse HTML on an external page and read its contents (eg.
I've tried to read a big xml file (something like 500MB). First of all,

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.