#!/usr/bin/env python #================================================================ # xmlcretest: Test driver for xml4create.py #---------------------------------------------------------------- import xml4create as xc doctype = xc.DocumentType ( "html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" ) doc = xc.Document ( "html", doctype ) head = xc.Element ( doc.root, "head" ) title = xc.Element ( head, "title" ) body = xc.Element ( doc.root, "body" ) xc.Text ( title, "This is the first title." ) h1 = xc.Element ( body, "h1", class_='major' ) xc.Text ( h1, "This is the second title." ) p1 = xc.Element ( body, "p" ) p1['id'] = 'a37' xc.Text ( p1, "This is the first paragraph." ) xc.Comment ( p1, "Here's a comment." ) doc.write()