[XML-SIG] Howto create this XML string?

Luis Miguel Morillas morillas at gmail.com
Thu Jan 19 20:04:27 CET 2006


2006/1/19, Sbaush <sbaush at gmail.com>:
>
> Hi all.
> I've this XML:
>
> <manager>
>     <request>
>         <append mode="INPUT">
>             <method type="GOOD"/>
>             <source address=" 127.0.0.1"/>
>             <action option="OK"/>
>         </append>
>     </request>
> </manager>
>
> How can i write this in a Python String? I would like use a xml.domimplementation and not a banal print...print...
> I can't do it... Is there anyone that can explain me what is the way?
> Thank you!



Another taste with amara:

import amara
doc = amara.create_document(u"manager")
doc.manager.xml_append(doc.xml_create_element(u'request'))
doc.manager.request.xml_append(doc.xml_create_element(
    u'append',
    attributes={u'mode':u'INPUT'}))
doc.manager.request.append.xml_append(doc.xml_create_element(
    u'method',
    attributes={u'type':u'GOOD'}))
doc.manager.request.append.xml_append(doc.xml_create_element(
    u'source',
    attributes={u'source':u'127.0.0.1'}))
doc.manager.request.append.xml_append(doc.xml_create_element(
    u'action',
    attributes={u'option':u'OK'}))
print doc.xml(indent='yes')




--

Luis Miguel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/xml-sig/attachments/20060119/66fc98b3/attachment.htm 


More information about the XML-SIG mailing list