Re: Tidy parsing with SAX-like callbacks, and node replacement

* John Kemp wrote:
>As far as I can tell, tidylib doesn't provide any callback interface so
>that I could tell when a particular element has been parsed (a la SAX),
>and there is no ability for me to replace a node, or set of nodes in the
>parsed tree. Have I got that right? Are there any plans to offer such an
>interface? 

There is no callback interface as the document structure of what has
been seen may change much later, e.g. when a <title> element inside the
<body> element is moved into the <head> element. The tree is also read-
only as far as the public interface is concerned. There are no plans to
change either. The usual approach is to traverse the built tree and map
it to whatever suits you, e.g. you could traverse it and generate SAX
events from the nodes in it. If you would like to use the pretty printer
after you have made modifications (in your own model), you can serialize
the document and pass it back to Tidy.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Friday, 15 January 2010 21:23:27 UTC