couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Walgran <>
Subject Re: Parsing HTML in CouchApp show functions?
Date Tue, 21 Jun 2011 12:10:47 GMT
Show functions are not run in a browser, so you do not have access to a DOM.
You will need to parse the HTML as a string.

If you have the option, it may be easier to reverse your design and store
JSON in your CouchDB documents then render HTML in a show function, rather
than the other way around.

If you are with decoding HTML, John Resig wrote a SAX-style parser that you
could bundle into your show function:


On Fri, Jun 17, 2011 at 2:01 PM, Greg Johnston <>wrote:

> Hi all,
> I'm trying to transform some HTML I have stored in a CouchDB document
> to another format. It's actually pretty simple to do, really just
> looping over the DOM. Normally I'd start out with something like:
> var div = document.createElement("div");
> div.innerHTML = [...]
> ...and be ready to go. Unfortunately it looks like "document" is
> undefined in the show function. Am I doing something stupid here, is
> there a better way, or does anyone have other suggestions?
> Thanks,
> Greg Johnston

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message