Wednesday, March 5th, 2008

CouchDB: Using E4X to get the XML back

Category: Database

<>p>Christopher Lenz has been spending time on the CouchDB project. He got lulled over when CouchDB went to JSON.

He talks about how “CouchDB is pretty well positioned for storing and querying XML data in addition to JSON” via the E4X support that it gets out of the box as it uses SpiderMonkey.

javascript
< view plain text >
  1. by_lang: function(doc) {
  2.   var html = new XML(doc.content);
  3.   map(html.@lang, {title: html.head.title.text(), …});
  4. }

To be fair, this is already possible if you use other view servers (such as the Ruby or Python ones), where you also have access to the XML support provided by the respective standard libraries. Given CouchDB’s incremental view update model, you usually don’t care so much about the performance of view functions as you care about the data it produces. So if your view function can somehow parse the XML and put some data into the view index, that’s usually all you need. Actually querying the view is going to be really fast.

But E4X is an exceptionally convenient API for XML. I think using E4X is going to be a pretty good approach for those who want to to CouchDB to store and query XML content.

Related Content:

  • NHS minister backs XML


    Antony Adshead

    Health minister Gisela Stuart told the NHS Information Authority's first national conference this week that...

  • Notes to XML. . .and back again
    Notes/Domino 6.x has robust tools for translating Notes data into XML and vice versa. IBM documentation lacks a simple sample showing the full...
  • XML import
    Use the Microsoft XML parser on a Domino...
  • XML and Web services: SOAP
    In this tip, William Brogden explains how using the AXIS toolkit and the JWS approach will get you started with a simple SOAP Web...
  • Using XSLT with XML
    +++--
    3.6 rating from 16 votes

1 Comment »

Comments feed TrackBack URI

I recommend using Exist for proper Xml/XQuery Support !
E4X is imo better suited as ClientSide Technology.

Regards
Rusco

Comment by Rusco — March 5, 2008

Leave a comment

You must be logged in to post a comment.