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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:38:08+00:00 2026-06-10T10:38:08+00:00

I’m building a RSS feed of my website using jquery and the link element

  • 0

I’m building a RSS feed of my website using jquery and the link element keeps returning blank. I do not have a problem with the javascript solution i built on my own but the jquery seems to hate the link element.

below is the jquery code:

function loadData(xml, ifid) {
        var htmlStr;
        var iframeToWrite = document.getElementById(ifid);

        htmlStr = "<html><body>"
        var items = $(xml).find("channel item").each(function () {
            var $article = $(this);
            var title = $article.find("title").text();
            var description = $article.find("description").text();
            var link = $article.find("link").text();
            var pubDate = $article.find("pubDate").text();

            htmlStr += "<div class='Rssitem'>\n";
            htmlStr += "\t<h3><a href='" + link + "' target='_blank' >" +
               title + "</a></h3>\n";
            htmlStr += "\t<p>" + description + "</p>\n";
            htmlStr += "\t<h6>" + pubDate + "</h6>\n";
            htmlStr += "</div>\n"
        });

        htmlStr += "</body></hmtl>";
        iframeToWrite.contentDocument.write(htmlStr);

    }

below is a sample xml i edited from the npr stream I get:

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:npr="http://www.npr.org/rss/" xmlns:nprml="http://api.npr.org/nprml" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title>News</title>
    <link>http://www.npr.org/templates/story/story.php?storyId=1001&amp;ft=1&amp;f=1001</link>
    <description>NPR news, audio, and podcasts. Coverage of breaking stories, national and world news, politics, business, science, technology, and extended coverage of major national and world events.</description>
    <language>en</language>
    <copyright>Copyright 2012 NPR - For Personal Use Only</copyright>
    <generator>NPR API RSS Generator 0.94</generator>
    <lastBuildDate>Tue, 28 Aug 2012 12:19:00 -0400</lastBuildDate>
    <image>
      <url>http://media.npr.org/images/npr_news_123x20.gif</url>
      <title>News</title>
      <link>http://www.npr.org/templates/story/story.php?storyId=1001&amp;ft=1&amp;f=1001</link>
    </image>
    <item>
      <title>Reports: Obama Administration Will Unveil New Fuel-Efficiency Standards</title>
      <description>The new rules will require U.S. cars to average 54.5 miles per gallon by 2025.</description>
      <pubDate>Tue, 28 Aug 2012 12:19:00 -0400</pubDate>
      <link>http://www.npr.org/blogs/thetwo-way/2012/08/28/160172356/reports-obama-administration-will-unveil-new-fuel-efficiency-standards?ft=1&amp;f=1001</link>
      <guid>http://www.npr.org/blogs/thetwo-way/2012/08/28/160172356/reports-obama-administration-will-unveil-new-fuel-efficiency-standards?ft=1&amp;f=1001</guid>
      <content:encoded><![CDATA[<p>The new rules will require U.S. cars to average 54.5 miles per gallon by 2025.</p><p><a href="http://www.npr.org/templates/email/emailAFriend.php?storyId=160172356">&raquo; E-Mail This</a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.npr.org%2Ftemplates%2Fstory%2Fstory.php%3FstoryId%3D160172356">&raquo; Add to Del.icio.us</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>
  • 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-10T10:38:09+00:00Added an answer on June 10, 2026 at 10:38 am

    You have to parse your xml string into a xml document first jQuery.parseXML().
    To quote the documentation:

    jQuery.parseXML uses the native parsing function of the browser to
    create a valid XML Document. This document can then be passed to
    jQuery to create a typical jQuery object that can be traversed and
    manipulated.

    If you don’t use parseXML and wrap a jQuery selector around it, jQuery may not be able to interpet all the nodes properly.

    In your example the <link> tags are not inerpeted correctly and the </link> closing tags have been removed without parsing, hence you cannot query the link text correctly.
    You can confirm that if you do a console.log($(this)) and check the content in the console output. You can see the <link> then text but the closing </link> is missing.

    However, when parsing your xml first to a document object you can now wrap a jQuery selector around it and access all nodes reliably. Off course, assuming the inital XML string was valid XML.

    DEMO – Using parseXml on your xml string and querying it after

    Applying this to your code would look similar to this:

    htmlStr = "<html><body>";
    
    // Parse the XML to a document object and then wrap it into a jQuery selector
    var $xml = $($.parseXML(xml));
    
    var items = $xml.find("channel item").each(function() {
        var $article = $(this);
         //..... rest of your code as is
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.