Re: Howto create this XML string?

Luis Miguel Morillas <[email protected]>
Newsgroups gmane.comp.python.xml
Message-ID <[email protected]>
2006/1/19, Sbaush <[email protected]>:
>
> 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

_______________________________________________
XML-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/xml-sig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.