Created
April 25, 2014 11:11
-
-
Save anupamshakya7/11285898 to your computer and use it in GitHub Desktop.
How to transform an XML file using XSLT in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml import etree | |
data = open('D:\Conversion\MACSXML_Parts.xslt') | |
xslt_content = data.read() | |
xslt_root = etree.XML(xslt_content) | |
dom = etree.parse('D:\Conversion\Cat2015UF.xml') | |
transform = etree.XSLT(xslt_root) | |
result = transform(dom) | |
f = open('D:\Conversion\MACSXML_Parts.csv', 'w') | |
f.write(str(result1)) | |
f.close() |
looks like it does not work with xls version 2..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import lxml.etree as ET
dom = ET.parse("XML.xml")
xslt = ET.parse("XSLT.xsl")
transform = ET.XSLT(xslt)
newdom = transform(dom)
print(ET.tostring(newdom, pretty_print=True))