<br><br><div class="gmail_quote">On Thu, Jan 7, 2010 at 8:44 AM, Phlip <span dir="ltr"><<a href="mailto:phlip2005@gmail.com">phlip2005@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Jan 7, 5:36 am, Stefan Behnel <<a href="mailto:stefan...@behnel.de">stefan...@behnel.de</a>> wrote:<br>
<br>
> Well, then note that there are tons of ways to generate XML with Python,<br>
> including the one I pointed you to.<br>
<br>
</div> from lxml.html import builder as E<br>
xml = E.foo()<br>
<br>
All I want is "<foo/>", but I get "AttributeError: 'module' object has<br>
no attribute 'foo'".<br>
<br>
A peek at dir(E) shows it only has HTML tags, all hard coded.<br>
<br>
So how to get it to generate any random XML tag my clients think of?<br></blockquote><div><br></div><div>If you want to generate random XML, don't use the HTML sub-module of lxml. Its a specific sub-set of functionality for HTML only documents.</div>
<div><br></div><div><div>>>> from lxml.builder import ElementMaker</div><div>>>> from lxml import etree</div><div>>>> E = ElementMaker()</div><div>>>> html = E.html(</div><div>... E.form(</div>
<div>... E.input(type="text", name="email"),</div><div>... E.input(type="text", name="blah")</div><div>... )</div><div>... )</div><div>>>> etree.tostring(html)</div>
<div>'<html><form><input type="text" name="email"/><input type="text" name="blah"/></form></html>'</div><div><br></div><div>HTH,</div><div>
<br></div></div></div><div name="mailplane_signature">--S</div>