0

I want to parse this RSS without Php:

<rss version="2.0">
  <channel>
    <item>
       <title>Test</title>
       <link>http://www.test.com</link>
       <image>
          <url>http://foo.bar/test.jpg</url>
       </image>
       <description>
       <![CDATA[Description text here!<br><a href="http://www.test.se" target="_blank" rel="external" data-ajax="false">Link!</a></div>]]>
       </description>
    </item>
  </channel>
</rss>

Can I accomplish this without Php? I'm a complete newbie in jQuery/javascript.. The XML is here: http://hundkartan.se/karta/kartdata/cron_webbutiker_mob.xml

I'm going to use this in phonegap so it's an EXTERNAL feed.

4
  • Did you try anything yet, or you expecting to be new to JavaScript forever? Commented Apr 5, 2013 at 8:31
  • I've tried several javascripts that I've found with some googleing. None of them has worked yet :/ Commented Apr 5, 2013 at 8:34
  • jquery: api.jquery.com/jQuery.parseXML Commented Apr 5, 2013 at 8:36
  • possible duplicate of Parsing XML / RSS from URL using Java Script Commented Apr 5, 2013 at 8:36

1 Answer 1

1

My advice is to use json with javascript. You can convert the XML into a json file with some external script (like this XML2JSON).

JSON is natively supported by javascript so access to a member is really simple. For example to obtain all link you can simply do:

<head>
    <script type="text/javascript" src="xml2json.js"></script>
    ...
</head>
...

<body> 
    <script>
    var json = xml2json.parser(XML_file);
    var channel = json.rss.channel;
    var links = [];
    for(var i = 0; i < channel.item.length; i++)
        links.push(channel.item[i].link);
    ...
    </script>
    ...
</body>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.