Python和xml:从xmlfi读取数据

2024-09-27 21:25:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个简单的python,其中定义了styledoc,如下所示

styledoc = libxml2.parseDoc("""
<xsl:stylesheet version='1.0'
  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
  xmlns:foo='http://example.com/foo'
  xsl:exclude-result-prefixes='foo'>

  <xsl:param name='bar'>failure</xsl:param>
  <xsl:template match='/'>
    <article><xsl:value-of select='foo:foo($bar)'/></article>
  </xsl:template>
</xsl:stylesheet>
""")

我想把所有的数据都包括在一个文件中读.xml像这样的东西

^{pr2}$

但是它给了我一个错误“read”没有定义。我犯了什么错误?在


Tags: http定义fooparamversion错误articlebar
1条回答
网友
1楼 · 发布于 2024-09-27 21:25:19

parseDoc接受一个包含XML的字符串,如第一个示例所示。要解析文件,请改为使用parseFile

styledoc = libxml2.parseFile("read.xml")

相关问题 更多 >

    热门问题