[Baypiggies] Constructing XML

Daniel González Gasull daniel at djansoft.com
Wed Oct 6 20:32:54 CEST 2010

I haven't used it much, but I like PyQuery: http://pypi.python.org/pypi/pyquery

Also, avoid XML at all if you can and use JSON instead or some other
format.  It will save you a few headaches.

On Wed, Oct 6, 2010 at 11:17 AM, Venkatraman S <venkat83 at gmail.com> wrote:
> 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
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies

http://DjanSoft.com :: Agile Application Development with Python

More information about the Baypiggies mailing list