【发布时间】:2013-05-17 22:16:16
【问题描述】:
美好的一天!需要在 Python 中使用 xslt 转换 xml。我在 php 中有一个示例代码。
如何在 Python 中实现这一点,或者在哪里可以找到类似的东西?谢谢!
$xmlFileName = dirname(__FILE__)."example.fb2";
$xml = new DOMDocument();
$xml->load($xmlFileName);
$xslFileName = dirname(__FILE__)."example.xsl";
$xsl = new DOMDocument;
$xsl->load($xslFileName);
// Configure the transformer
$proc = new XSLTProcessor();
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToXML($xml);
【问题讨论】: