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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:57:50+00:00 2026-05-27T15:57:50+00:00

Im getting Rss from a site. in the description tag there is an image

  • 0

Im getting Rss from a site. in the description tag there is an image that i would like to show to the users. I m using this code to get it:

public void setDescription(String description) {
        this.description = description;
        //parse description for any image or video links
        if (description.contains("<img style=")){
            String imgg  = description.substring(description.indexOf("<img style="));
            String cleanUp = imgg.substring(0, imgg.indexOf(">")+1);
            imgg = imgg.substring(imgg.indexOf("src=") + 5);
            int indexOf = imgg.indexOf("\"");
            if (indexOf==-1){
                indexOf = imgg.indexOf("\"");
            }
            imgg = imgg.substring(0, indexOf);

            setImgLink(imgg);

            this.description = this.description.replace(cleanUp, "");
        }   else{

            String imgg2="replace_image.png";
            setImgLink(imgg2);
        }

    }

My problem is that if the site i m getting the rss changes something in the xml,i m getting my replace image.For example,if the img style change to image src or something like this.

Is there any way to fix it and get everytime the images from the description??
I have found that i can use something like this but i can’t make it work http://developer.android.com/reference/android/text/Html.html

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-05-27T15:57:51+00:00Added an answer on May 27, 2026 at 3:57 pm

    Rather than using regex its better to use DOM and XPATH to extract the image source. This way even if the HTML changes, your solution will still work.

    It seems you have the description in description and you want the image path in imgg. Try this:

    DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
    builderFactory.setNamespaceAware(true);
    DocumentBuilder builder = builderFactory.newDocumentBuilder();
    Document document = builder.parse(description);
    
    XPath xpath = XPathFactory.newInstance().newXPath();
    String expression = "//img";
    Node imgNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
    
    String imgg = imgNode.getAttribute("src");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using rome 0.9 for getting rss feeds.but from that getting blog post's
Has anyone experience getting values from a RSS-CB file, I would like to get
I am getting news from Yahoo using an RSS feed, using: XML.load(http://finance.yahoo.com/rss/topstories) Yea this
I have an RSS feed that I'm setting up on my new site using
i am creating rss reader application with php.it is basicly getting rss url's from
I want to track how much traffic I'm getting on an RSS feed that
i am getting Rss Feed from my DB but i am getting all feeds
Is there any way of getting the weather forecast from woeid in javascript? I
Context: I'm building a little site that reads an rss feed, and updates/checks the
i have wrote an app getting rss feed from the website of my university.in

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.