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

The Archive Base Latest Questions

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

Hi i want to parse xml/rss from a live url like http://rss.news.yahoo.com/rss/entertainment using pure

  • 0

Hi i want to parse xml/rss from a live url like http://rss.news.yahoo.com/rss/entertainment using pure Java Script(not jquery). I have googled a lot. Nothing worked for me. can any one help with a working piece of code.

  • 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-27T11:19:46+00:00Added an answer on May 27, 2026 at 11:19 am

    (You cannot have googled a lot.) Once you have worked around the Same Origin Policy, and if the resource is served with an XML MIME type (which it is in this case, text/xml), you can do the following:

    var x = new XMLHttpRequest();
    x.open("GET", "http://feed.example/", true);
    x.onreadystatechange = function () {
      if (x.readyState == 4 && x.status == 200)
      {
        var doc = x.responseXML;
        // …
      }
    };
    x.send(null);
    

    (See also AJAX, and the XMLHttpRequest Level 2 specification [Working Draft] for other event-handler properties.)

    In essence: No parsing necessary. If you then want to access the XML data, use the standard DOM Level 2+ Core or DOM Level 3 XPath methods, e.g.

    /* DOM Level 2 Core */
    var title = doc.getElementsByTagName("channel")[0].getElementsByTagName("title")[0].firstChild.nodeValue;
    
    /* DOM Level 3 Core */
    var title = doc.getElementsByTagName("channel")[0].getElementsByTagName("title")[0].textContent;
    
    /* DOM Level 3 XPath (not using namespaces) */
    var title = doc.evaluate('//channel/title/text()', doc, null, 0, null).iterateNext();
    
    /* DOM Level 3 XPath (using namespaces) */
    var namespaceResolver = (function () {
      var prefixMap = {
        media: "http://search.yahoo.com/mrss/",
        ynews: "http://news.yahoo.com/rss/"
      };
    
      return function (prefix) {
        return prefixMap[prefix] || null;
      };
    }());
    
    var url = doc.evaluate('//media:content/@url', doc, namespaceResolver, 0, null).iterateNext();
    

    (See also JSX:xpath.js for a convenient, namespace-aware DOM 3 XPath wrapper that does not use jQuery.)

    However, if for some (wrong) reason the MIME type is not an XML MIME type, or if it is not recognized by the DOM implementation as such, you can use one of the parsers built into recent browsers to parse the responseText property value. See pradeek’s answer for a solution that works in IE/MSXML. The following should work everywhere else:

    var parser = new DOMParser();
    var doc = parser.parseFromString(x.responseText, "text/xml");
    

    Proceed as described above.

    Use feature tests at runtime to determine the correct code branch for a given implementation. The simplest way is:

    if (typeof DOMParser != "undefined")
    {
      var parser = new DOMParser();
      // …
    }
    else if (typeof ActiveXObject != "undefined")
    {
      var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      // …
    }
    

    See also DOMParser and HTML5: DOM Parsing and Serialization (Working Draft).

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

Sidebar

Related Questions

I want to parse information in: http://feeds.informationweek.com/infoweek/news http://feeds.news.com.au/public/rss/2.0/fs_breaking_news_13.xml http://rss.cnn.com/rss/cnn_topstories.rss using php. And save the
i try to parse within my iPhone SDK 4 http://de.news.search.yahoo.com/news/rss?p=iphone&ei=UTF-8&fl=0&x=wrt there are some german
I am using this feed http://feeds.bbci.co.uk/news/rss.xml and want to get all media:thumbnail entries. I.e.
i want parse xml file, which does't have xml extension, like this: http://bizonek.wrzuta.pl/xml/plik/1ANdXCgTOit/unknow/undefined/643/ my
I want to parse xml files that have elements like these: <element>&amp</element> <element>&amp;</element> But
I want to parse a couple of thousands XML-files from a website(I have permission)
I have some XML that I want to parse using the lxml method in
I want to parse the following xml and get the value of metadata:description using
Like the title says, I want to parse XML in my iPhone application, but
I want to parse an XML file using Perl . I was able to

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.