Python code examples that _generate_ HTML/XML?
Alessandro Bottoni
alessandro.bottoni at infinito.it
Fri Oct 18 03:58:06 EDT 2002
Alle 22:29, giovedì 17 ottobre 2002, hai scritto:
> I'm creating an app for use in-house, that will assist a user (complete
> novice) in creating web pages. So after they complete a session I will
> need to take their "instructions" and generate the items necessary to
> display the desired pages in a browser. Therefore I'll be creating the
> HTML/XML tags and code dynamically for things like list boxes, buttons,
> hrefs, graphics, etc. Has anybody seen any code samples or URL's for such
> that show how to do this in Python? Are there parts of the Zope source
> code that might be helpful to look at, if so what 'py' files?
>
> thx
Robert, if you just have to generate HTML tags (code) from within a Python
program, you can take advantage of the HTMLGen library by Robin
Friedrichs. You can find it at:
http://starship.python.net/crew/friedrich/HTMLgen/html/main.html
and:
http://www.zenspider.com/Languages/Python/HTMLGen.html
That is not the only one: I think you can find a large collection of tools
like HTMLGen at the "Vaults of Parnassus "web site (see the python main web
site fot the link) and at other python-devoted sites on the web. Try "HTML"
and "Python" from Google or Yahoo, as well.
Of course, you can just print HTML code to the standard output, or any other
file, with a simple "print" instruction, as well.
For example:
print "<h1>My Title</h1>"
or:
content = "The world"
initag = "<h1>"
endtag = "</h1>"
output = initag + content + " is not enough "+endtag
print output
(check the python manual for the characters of your text and of your tags
that need to be backslashed prior of printing, most likely "\", "/" and "<",
">" )
---------------------
Alessandro Bottoni
More information about the Python-list
mailing list