How to apply text changes to HTML, keeping it intact if inside "a" tags

Diez B. Roggisch deets at nospam.web.de
Wed Sep 27 14:23:13 CEST 2006


vbfoobar at gmail.com wrote:

> Hello,
> 
> I have HTML input to which I apply some changes.
> 
> Feature 1:
> =======
> I want to tranform all the text, but if the text is inside
> an "a href" tag, I want to leave the text as it is.
> 
> The HTML is not necessarily well-formed, so
> I would like to do that using BeautifulSoup (or
> maybe another tolerant parser).
> 

<snip/>

Use the BeautifulSoup + XSL. Writing your two features in xsl is close to a
no-brainer, and it is certainly the best tool for the job.

And there are a few implementations for python available.

Diez



More information about the Python-list mailing list