0

I have a RSS/Atom document that has a bunch of

<entry>
    <title>project name</title>
    <link href="url" rel="alternate"/>
    <id>url</id>
    <updated>2012-01-03T09:01:16-04:00</updated>
    <content type="html">
    </content>
</entry>

and starts with

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>PROJECTS</title>
  <link href="/projects.atom" rel="self"/>
  <link href="/projects" rel="alternate"/>
  <id>url</id>
  <updated>2012-01-03T09:01:16-04:00</updated>
  <author>
    <name>Myself</name>
  </author>
  <generator uri="http://www.redmine.org/">
Redmine  </generator>

and I want to parse it and get every <entry> and put it into an array so I can then transfer it to HTML. So I would end up with a javascript multidimensional array something like {'url'=url, 'name'=name},{'url'=url2, 'name'=name2},etc

Any idea of how I could do this? I'm a bit stuck.

bjornd
  • 22,397
  • 4
  • 57
  • 73
Steven
  • 13,250
  • 33
  • 95
  • 147
  • 1
    Have a look at this post http://stackoverflow.com/a/8412989/525558 searched "javascript parse xml" and it was the fifth post in Google. Good Luck! – Craig Jan 05 '12 at 16:50

1 Answers1

2

You have a direct function for this :

http://api.jquery.com/jQuery.parseXML/

Hope this helps

jflaflamme
  • 1,767
  • 12
  • 9
  • 3
    Is it possible without using a giant library of which 99.9% I won't use? – Steven Jan 05 '12 at 16:45
  • 1
    +1 for jQuery. @Steven of course you ca roll your own, if you really want to, look at the jQuery method source. – Craig Jan 05 '12 at 16:47
  • Sorry, my bad, read to fast the question and assumed it was jquery – jflaflamme Jan 05 '12 at 16:47
  • 2
    @Steven You can have a look at the source, and create a custom function, inspired by their implementation of `parseXML`: http://code.jquery.com/jquery-1.7.1.js – Rob W Jan 05 '12 at 16:51