I hope I'm wrong, but seems that DOMBuilder, found among the various
xml.dom packages, cannot build DOM like this:
var html = DomBuilder.apply();
var form = html.FORM(
html.DIV(
html.INPUT({type : 'text', name : 'email'}),
html.INPUT({type : 'text', name : 'password'}),
html.INPUT({type : 'submit'}),
)
);
Do anyone know any good DOM builder packages that do build DOM good
like a DOM builder should?
--
Phlip
http://zeekland.zeroplayer.com/Uncle_Wiggilys_Travels/1
You might be looking for something like this:
http://codespeak.net/lxml/lxmlhtml.html#creating-html-with-the-e-factory
Note that there are tons of ways to generate HTML with Python. A quick web
search (or a quick read on PyPI or the Python Wiki) should get you started.
Stefan
> Note that there are tons of ways to generate HTML with Python.
Forgot to note - I'm generating schematic XML, and I'm trying to find
a way better than the Django template I started with!
Well, then note that there are tons of ways to generate XML with Python,
including the one I pointed you to.
Stefan
> Well, then note that there are tons of ways to generate XML with Python,
> including the one I pointed you to.
from lxml.html import builder as E
xml = E.foo()
All I want is "<foo/>", but I get "AttributeError: 'module' object has
no attribute 'foo'".
A peek at dir(E) shows it only has HTML tags, all hard coded.
So how to get it to generate any random XML tag my clients think of?
I will write this myself with __getattr__ etc, if I can't find it,
because the permissive & expressive builder pattern I'm after would be
very ... permissive & expressive.
All I want is a library that reads my mind!!! Is that too much to
ask??? (Unless if the library insists on throwing a NullMind
exception, on principle...)
--
Phlip
http://twitter.com/Pen_Bird
Note how you imported 'E' from a package called 'lxml.html'. The last part
of that package name gives a hint on what it specialises in.
> So how to get it to generate any random XML tag my clients think of?
Have you thought of taking a look at the tutorial?
http://codespeak.net/lxml/tutorial.html#the-e-factory
Stefan