473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

sending out XML from python.

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
5 1370
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Gerhard Häring | last post by:
On my mailserver (running a recent Postfix snapshot) I get this since a few hours: mylene:/var# mailq -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- DA10713E37 1617 Wed...
0
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils...
1
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils...
3
by: Sells, Fred | last post by:
I'm using MSW XP Pro with Python 2.4 to develop but production will be Linux with Python 2.3. (could upgrade to 2.4 if absolutely necessary) I can also switch to Linux for development if...
1
rhitam30111985
by: rhitam30111985 | last post by:
Hi all .. i am trying to do something really weird ... here is my code : import os os.system("mail -s test xxx@gmail.com asdaskdjkasdaasdad")
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.