By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,818 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,818 IT Pros & Developers. It's quick & easy.

sending out XML from python.

P: n/a
I am going to be doing some programming with a Flash programmer in my
company. Most of the online docs about integrating Flash with another
language use PHP. I am not a fan of PHP.

What I would really like to do is use Python to create data in the form of
XML to send back to Flash, since Flash MX has the ability to easily parse
XML to get variables and values.

I have done some reading on XML in Python, but only stuff I have seen has
been geared toward reading in XML data, not spitting it out.

Is there a module for doing this? I know that I can make something that
would work, but wondered if it is already done.

Thanks
Jul 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Tue, 11 May 2004 18:27:03 -0700, Sean Berry wrote:
I am going to be doing some programming with a Flash programmer in my
company. Most of the online docs about integrating Flash with another
language use PHP. I am not a fan of PHP.

What I would really like to do is use Python to create data in the form of
XML to send back to Flash, since Flash MX has the ability to easily parse
XML to get variables and values.

I have done some reading on XML in Python, but only stuff I have seen has
been geared toward reading in XML data, not spitting it out.

Is there a module for doing this? I know that I can make something that
would work, but wondered if it is already done.

Thanks


Absolutely! My favorite way is to use the minidom to construct an XML
document in memory, and then use node.toxml() to generate the content.
(You can also use toprettyxml() while you are debugging if you want it to
be readable.) The python documentation has lots of good information about
the available XML tools. I made a wrapper for the minidom that lets me use
simple operators to append nodes and traverse the tree.

Additionally, I sometimes find that it is easier to make an xml output
function in a particular class that builds an xml document from the class
dictionary.

Also, in some situations, it may make more sense just to write out the xml
code and replace parts of it with python:

"""
<doc>
<test1 prop="%(test1prop)s"/>
</doc>
"""%{'test1prop':'asdf'}

--Segphault
Jul 18 '05 #2

P: n/a
Sean Berry wrote:
I am going to be doing some programming with a Flash programmer in my
company. Most of the online docs about integrating Flash with another
language use PHP. I am not a fan of PHP.

What I would really like to do is use Python to create data in the form of
XML to send back to Flash, since Flash MX has the ability to easily parse
XML to get variables and values.

I have done some reading on XML in Python, but only stuff I have seen has
been geared toward reading in XML data, not spitting it out.

Is there a module for doing this? I know that I can make something that
would work, but wondered if it is already done.


It's often the case that the simplest thing is just to build
up the strings from scratch. Constructing an awkward
in-memory representation (ala DOM) just to serialize it
immediately can be a trying experience.

How complicated will your XML be?

-Peter
Jul 18 '05 #3

P: n/a
Brad Clements wrote:
Also consider elementtree

http://effbot.org/zone/element-index.htm


And pygenx, which is specifically designed for this task:

http://software.translucentcode.org/pygenx/

And it wouldn't hurt to spend 20 minutes poking around Uche's treatises
on the topic:

http://www.xml.com/pub/a/2003/10/15/py-xml.html

Paul Prescod

Jul 18 '05 #4

P: n/a
Also consider elementtree

http://effbot.org/zone/element-index.htm

--
Novell DeveloperNet Sysop #5

_
"Peter Hansen" <pe***@engcorp.com> wrote in message
news:3o********************@powergate.ca...
Sean Berry wrote:
I am going to be doing some programming with a Flash programmer in my
company. Most of the online docs about integrating Flash with another
language use PHP. I am not a fan of PHP.

What I would really like to do is use Python to create data in the form of XML to send back to Flash, since Flash MX has the ability to easily parse XML to get variables and values.

I have done some reading on XML in Python, but only stuff I have seen has been geared toward reading in XML data, not spitting it out.

Is there a module for doing this? I know that I can make something that
would work, but wondered if it is already done.


It's often the case that the simplest thing is just to build
up the strings from scratch. Constructing an awkward
in-memory representation (ala DOM) just to serialize it
immediately can be a trying experience.

How complicated will your XML be?

-Peter
--
http://mail.python.org/mailman/listinfo/python-list



Jul 18 '05 #5

P: n/a
Paul Prescod <pa**@prescod.net> wrote in message news:<ma**************************************@pyt hon.org>...
Brad Clements wrote:
Also consider elementtree

http://effbot.org/zone/element-index.htm


And pygenx, which is specifically designed for this task:

http://software.translucentcode.org/pygenx/

And it wouldn't hurt to spend 20 minutes poking around Uche's treatises
on the topic:

http://www.xml.com/pub/a/2003/10/15/py-xml.html


Since emitting XML is usually more complex than people think, I also
recommend the article in which I go over basic principles:

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

--Uche
http://uche.ogbuji.net
Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.