[Baypiggies] Constructing XML

Venkatraman S venkat83 at gmail.com
Wed Oct 6 20:17:10 CEST 2010


Hi,

I was wondering whether there is a better way (or an elegant 'pattern') to
construct an xml document. Lets say I have many variables(can be lists,
dicts, strings etc) and the corresponding values, so some tags have just one
text value whereas some have siblings etc and also have their respective
attributes. Is it possible to construct the XML just based on this structure
of variables.

I am not sure whether I am framing my Q right, but let me explain it with an
example:
strtag="Hello World"
listtag = [10,20,30]
dicttag={'a':100,'b':200}

And when the above variables are fed into a black box, i get the output xml:
<strtag>Hello World</strtag>
<listtag>10</listtag>
<listtag>20</listtag>
<listtag>30</listtag>
<dicttag>
  <a> 100</a>
  <b> 200</b>
</dicttag>

The above example 'again' might not make sense exactly in terms of how the
black box deciphers how the xml hierarchy can be maintained; I am looking
for a better example !!

-V-
http://twitter.com/venkasub
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20101006/c2154bb8/attachment.html>


More information about the Baypiggies mailing list