简体   繁体   中英

JavaScript parse atom?

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.

You have a direct function for this :

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

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM