Thanks Christoph,
That did just the trick.
-Chris

On 8/12/06, Christoph Zwerschke <[EMAIL PROTECTED]> wrote:
> Chris Lee-Messer wrote:
> > I am experimenting with generating html fragments for an ajax
> > interface using kid.
> > I therefore do not need a doctype and closing body.
> > I can't figure out how to do this from within the kid framework, and I
> > don't see away at getting at the underlying structure---something like
> > an elementtree ?  Currently, I'm having kid generate the xml and then
> > I'm cutting off the header and footer in outside code so as to just
> > get the html inside the <body> </body> tags.  My method seems
> > inefficient and brittle.
>
> You can easily serialize XML without doctype and XML declaration:
>
> serializer = kid.XMLSerializer(decl=False)
> print your_template.serialize()
>
> You can also do this with the HTML serializer:
>
> serializer = kid.HTMLSerializer()
> serializer.doctype = None
> print your_template.serialize()
>
> If you want to get rid of the root element and only output the inner
> fragment (i.e. head and body in a HTML document), you must "strip" it
> from the element stream:
>
> stream = kid.ElementStream(my_template.Template())
> stream = stream.strip()
> print serializer.serialize(stream)
>
> If you want only the body element, you must "eat" the head element:
>
> stream = kid.ElementStream(my_template.Template())
> stream =  kid.ElementStream(stream.strip()).eat()
> print serializer.serialize(stream)
>
> You can strip() once more to get only the elements inside the body.
>
> Hope that helps.
>
> -- Christoph
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> kid-template-discuss mailing list
> kid-template-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kid-template-discuss
>


-- 
Christopher Lee-Messer MD PhD
Resident in Pediatric Neurology
Stanford Medical Center
chris (at) lee-messer.net

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
kid-template-discuss mailing list
kid-template-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kid-template-discuss

Reply via email to