stripping fields from xml file into a csv

Roland Mueller roland.em0001 at googlemail.com
Sun Feb 28 08:21:26 EST 2010


2010/2/28 Stefan Behnel <stefan_ml at behnel.de>

> Roland Mueller, 28.02.2010 13:01:
> > The stylesheet is test.xsl and the insput data test.xml. The following
> > Python code the applies the stylesheet on the input data and puts the
> output
> > into foo.
> >
> > Python code:
> > #!/usr/bin/python
> > import sys
> > import libxml2
> > import libxslt
> >
> > styledoc = libxml2.parseFile("test.xsl")
> > style = libxslt.parseStylesheetDoc(styledoc)
> > doc = libxml2.parseFile("test.xml")
> > result = style.applyStylesheet(doc, None)
> > style.saveResultToFilename("foo", result, 0)
> >
> > BR,
> > Roland
> >
> > *Example run in Linux:*
> > roland at komputer:~/Desktop/XML/XSLT$ ./xslt_test.py
>
> Note that the shorthand for the above is
>
>    $ xsltproc test.xsl test.xml > foo
>
> yes, that's true, and probably the best way to use XML stylesheets in
Linux.

However, this is a Python ML, and so I was sending the Python example. The
original poster does not necessarily use Linux, and I do not know about
Windos tools in that regard.

BR,
Roland


> Stefan
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100228/1c6984b3/attachment-0001.html>


More information about the Python-list mailing list