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.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

22 Responses to “jParse: Easily Parse XML with jQuery”

  1. kylerush says:

    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.

  2. mupet says:

    What kind of license this plugin released?

  3. kylerush says:

    thanks for the suggestions jared. they're already on my to-do list =)

  4. dekztah says:

    for me, even the demo on your homepage wont display anything.
    FF3.6b1, IE7, Chrome 3.0.195

  5. @sedatkumcu says:

    thanks for this great article

  6. Shen says:

    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.

    • kylerush says:

      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.

  7. Orson says:

    Nice work.

  8. Johnd says:

    You did a good work for sure! good article!

  9. Nic Johnson says:

    What an awesome way to interact with an xml feed!

  10. sergey says:

    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!

    • kylerush says:

      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.

  11. Randy says:

    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'/>

  12. Randy says:

    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.

  13. garystafford says:

    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>

Leave a Reply