XML Writer in wxPython

M

Marco Meoni

Have you ever write an XML Writer in wxPython? A Writer that from a GUI
can compose XML Files.
Thanks.
Marco.
 
T

Tim Roberts

Marco Meoni said:
Have you ever write an XML Writer in wxPython? A Writer that from a GUI
can compose XML Files.

XML is usually pretty easy to write by hand, just using print statements.
Do you alreday have a tree of objects you want to write?
 
T

Tim Roberts

Marco Meoni said:
Could you post an example please?

Not really; it depends on what it is you're writing.


def PrintAddress( last, first, address, city, state, zip ):
print " <address>"
print " <lastname>%s</lastname>" % last
print " <firstname>%s</firstname>" % first
print " <address1>%s</address1>" % address
print " <city>%s</city>" % city
print " <state>%s</state>" % state
print " <zip>%s</zip>" % zip
print " </address>"

print "<addresses>"
for row in addressDatabase:
PrintAddress( row.last, row.first,
row.address, row.city, row.state, row.zip )
print "</addresses>"


You can see how an HTML templating aid could help here.
 
M

Marco Meoni

i have to put the XML in a string. Is there a module with the XML
writing funcion?
 
U

uche.ogbuji

Tim Roberts wrote re using print to generate XML:
def PrintAddress( last, first, address, city, state, zip ):
print " <address>"
print " <lastname>%s</lastname>" % last
print " <firstname>%s</firstname>" % first
print " <address1>%s</address1>" % address
print " <city>%s</city>" % city
print " <state>%s</state>" % state
print " <zip>%s</zip>" % zip
print " </address>"

print "<addresses>"
for row in addressDatabase:
PrintAddress( row.last, row.first,
row.address, row.city, row.state, row.zip )
print "</addresses>"

Just be sure you're well aware of all the issues:

http://www.xml.com/pub/a/2002/11/13/py-xml.html

See also:

http://www.ibm.com/developerworks/xml/library/x-think35.html
 
U

uche.ogbuji

Tim Roberts wrote re using print to generate XML:
def PrintAddress( last, first, address, city, state, zip ):
print " <address>"
print " <lastname>%s</lastname>" % last
print " <firstname>%s</firstname>" % first
print " <address1>%s</address1>" % address
print " <city>%s</city>" % city
print " <state>%s</state>" % state
print " <zip>%s</zip>" % zip
print " </address>"

print "<addresses>"
for row in addressDatabase:
PrintAddress( row.last, row.first,
row.address, row.city, row.state, row.zip )
print "</addresses>"

Just be sure you're well aware of all the issues:

http://www.xml.com/pub/a/2002/11/13/py-xml.html

See also:

http://www.ibm.com/developerworks/xml/library/x-think35.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,283
Messages
2,571,409
Members
48,103
Latest member
MadieDeitz

Latest Threads

Top