[XML-SIG] pydom

Andrew M. Kuchling akuchlin@cnri.reston.va.us
Fri, 9 Oct 1998 10:57:29 -0400 (EDT)


Jeff.Johnson@stn.siemens.com writes:
>Consider the following using pyhtml.py:
>
>     html =
>HTML(HEAD(TITLE(self.title)),BODY(list,BACKGROUND=self.background))
>

	The builder.py module may help; using it, the code would look
something like:


from xml.dom import builder
b=builder.Builder()
b.startElement('HTML', {})
b.startElement('HEAD', {})
b.startElement('TITLE', {})

'print b.document.toxml()' outputs:
'<?xml version="1.0"?>\012<!DOCTYPE XXX>\012<HTML><HEAD><TITLE/></HEAD></HTML>'


b.text("title Text")
print b.document.toxml()
'<?xml version="1.0"?>\012<!DOCTYPE XXX>\012<HTML>
<HEAD><TITLE>title Text</TITLE></HEAD></HTML>' 

b.pop()
b.pop()
b.startElement('BODY', {'BACKGROUND':'#00ffff'})
print b.document.toxml()
'<?xml version="1.0"?>\012<!DOCTYPE XXX>\012<HTML>
<HEAD><TITLE>title Text</TITLE></HEAD>
<BODY BACKGROUND=\'#00ffff\'/></HTML>' 

-- 
A.M. Kuchling			http://starship.skyport.net/crew/amk/
The Social Sciences are good at accounting for disasters once they have taken
place.
    -- Claude T. Bissell