1

I have a simple python, in which i have defined styledoc as follows

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>
""")

I want to have something like all the data included in a file read.xml and something like this

styledoc = libxml2.parseDoc("read.xml");

but it gives me an error 'read' is not defined. What mistake am I doing?

2
  • 1
    We need the exact error and the exact code that causes it (propably including a bit of context). Commented Jan 10, 2011 at 21:17
  • Perhaps you are looking for libxml2.parseFile? Commented Jan 10, 2011 at 21:23

1 Answer 1

2

parseDoc takes a string containing XML, as shown in your first example. To parse a file use parseFile instead:

styledoc = libxml2.parseFile("read.xml")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.