Reputation: 1515
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.
Upvotes: 0
Views: 1839
Reputation: 800
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>
Upvotes: 1