jParse: Easily Parse XML with jQuery
by: Kyle Rush
Categories: JavaScript, Plugin, Uncategorized, jQuery
Tags: jparse
Comments: 19
Nov
09
09
Today I launched the site of a jQuery plugin that I’ve been working on called jParse. The plugin allows you to easily parse XML that has been fetched with an Ajax request. The plugin works off of jQuery’s ajax method, so all of the same options are available. In terms of parsing, the plugin gives you a few options: Custom Output, Limit, Count of Items and the ability to run functions before and after jParse is finished.
jParse Demo:
The following is populated by jParse from the main RSS feed of this site.
Hey Kyle, the demo's not working in Chrome 4.0.237.0 (the latest)
Your demo doesn’t seem to work with the latest Chrome beta
thanks steven and stephen. the version of jparse that i have out oddly only works with some xml feeds in chrome, so it slipped past my qa checks. i'm looking into the issue now.
What kind of license this plugin released?
MIT
thanks for the suggestions jared. they're already on my to-do list =)
for me, even the demo on your homepage wont display anything.
FF3.6b1, IE7, Chrome 3.0.195
thanks for this great article
Very nice work – very simple to get going. However, how can I distinguish between tags which are separated by their values? For example, I have xml which contains this:
<image type="large">1.jpg</image>
<image type="thumb">2.jpg</image>
Thanks.
thank you @shen. an option to differentiate between nodes with the same name will be coming in the next feature release–hopefully this weekend. the plugin is still in beta, so there are a good amount of features that are still being worked on.
Nice work.
You did a good work for sure! good article!
What an awesome way to interact with an xml feed!
Thanks for the plugin! but… 8(
Tell me please how I can parse only certain elements from xml file?
'
Example i wish parse only 2 elements with their value, this is element with title 'elem1' and element with title 'elem2'
please…. thanks! hello from Russia!
hi sergey,
i've released a few updated versions of jparse that may help you. please take a look.
Can it parse xml like this? http://bit.ly/90Kvwy
i don't see why not. jparse is built so that it can easily parse xml nodes with namespaces. so if you want to pull the username, the elementTag option for jParse would look like this:
elementTag: ['ns3:userName']
see the jparse usage page for more.
Do you have an example of using the attr option? i am trying to pull a value of a tag that contains my url to a podcast. i have set it as
attr: [{elem: 'enclosure', attr: 'url'}]
but i can't seem to get it to pull the value, actually i can't get it to pull any values. example of the XML
<enclosure url='http://something.com/podcast233.mp3' length='13051569' type='audio/mpeg'/>
You can ignore my last post, i figured it out, and actually what was causing me some problems is around line 130 in the jparse script file, i was getting a console error, i just commented it out and i am all good now.