美好的一天!需要在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);
Run Code Online (Sandbox Code Playgroud)