stripping fields from xml file into a csv

Stefan Behnel stefan_ml at behnel.de
Sun Feb 28 07:15:09 EST 2010


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

Stefan




More information about the Python-list mailing list