Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0A86C45F8 for ; Tue, 21 Jun 2011 12:11:16 +0000 (UTC) Received: (qmail 35790 invoked by uid 500); 21 Jun 2011 12:11:14 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 35750 invoked by uid 500); 21 Jun 2011 12:11:14 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 35742 invoked by uid 99); 21 Jun 2011 12:11:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jun 2011 12:11:14 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jwalgran@azavea.com designates 209.85.214.52 as permitted sender) Received: from [209.85.214.52] (HELO mail-bw0-f52.google.com) (209.85.214.52) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jun 2011 12:11:09 +0000 Received: by bwj24 with SMTP id 24so3052358bwj.11 for ; Tue, 21 Jun 2011 05:10:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=azavea.com; s=google; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=S6jmslKCitHet1vc7bQ2ydCscqS3CfOtCy6TNz0xW78=; b=aAMiZR5HALQiYxPVrEdIAPwm9176GTfP8R2MgjrGVrKmygETmQenogDLhhYuhxwm/m 5lWSAXF/4E4DhcCgUbFM6gHsP3rG4ucviSQKFTC4eJWoIQfAQ6AMNaZ4RkbH0zWndJb3 4EzQDG228hrA0lp6YwzvHzobSX0OHMMltIhK4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=azavea.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=KSq+mH0bJKVmykUI5QSuFuJhN91MUo2Z8gE7CXL/AIEL9r6EXcvj4MqPLtGSInFmGC PJoWf/vCaMJbLyh8vAg2T6JCx2MyGKfs1Dgw+OuM9/up/JlPOec8mwGyuMI0ZPBaZw9k 4ppONd4ALG+JIDPf7e0Od8onWpsHfLXzzOQ7A= MIME-Version: 1.0 Received: by 10.204.14.208 with SMTP id h16mr980479bka.35.1308658247296; Tue, 21 Jun 2011 05:10:47 -0700 (PDT) Received: by 10.204.83.31 with HTTP; Tue, 21 Jun 2011 05:10:47 -0700 (PDT) In-Reply-To: References: Date: Tue, 21 Jun 2011 08:10:47 -0400 Message-ID: Subject: Re: Parsing HTML in CouchApp show functions? From: Justin Walgran To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=000325556062f6665204a637bd33 --000325556062f6665204a637bd33 Content-Type: text/plain; charset=ISO-8859-1 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: http://ejohn.org/blog/pure-javascript-html-parser/ Justin 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 > --000325556062f6665204a637bd33--