jParse: Easily Parse XML with jQuery
by: Kyle Rush
Categories: JavaScript, Plugin, Uncategorized, jQuery
Tags: jparse
Comments: 22
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.
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.
Kyle – Great plug-in! Thank you. One suggestion and a question. Suggestion, it took me a while to figure out the parentElement: 'item' default option in your script and that I could change that option on the page. I suggest adding that to your usage page as an available option. It's key to everything working correctly. And a question, is there a way to make XML in the following format list all papers and options correctly. I haven't been able to make it work using a combination of attr and parentElement options. Papers is the top-level parent node and the child nodes are each type of paper in my web-to-print application.
<papers>
<paper id="PLPP" cost="0.022" title="Epson Premium Luster Photo Paper" />
<paper id="CRPP" cost="0.030" title="Canson Rag Photographique Fine Art Paper" />
<paper id="TFAP" cost="0.030" title="Epson Textured Fine Art Paper by Crane" />
</papers>
Hi Gary. Thanks for the feedback. I really appreciate it.
The parentElement must've slipped by me when I was documenting the options. I'll get that documented on the usage page when I get the chance. Thanks for pointing that out.
Can you link me to your XML page so that I can take a look at the entire document? Thanks.
Thanks, Kyle. Here's a link: Papers
Thanks, Kyle. Here's a link: Papers
Thanks, Kyle. Here's a link: Papers