0

I'm learning Xpath and XSLT using Python 2.6.6-64bit on my unix workstation. For Xpath, I'm using the xpath module provided in PyXml-0.8.4.

However, the import line itself throws the following error:

Traceback (most recent call last):
  File "xp.py", line 7, in <module>
    from xml.xpath          import Evaluate
  File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/__init__.py", line 112, in <module>
    from pyxpath import ExprParserFactory
  File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/pyxpath.py", line 59, in <module>
    from xml.xpath.ParsedAbbreviatedRelativeLocationPath import ParsedAbbreviatedRelativeLocationPath
  File "/usr/local/python-2.6.6-64bit/lib/python2.6/site-packages/_xmlplus/xpath/ParsedAbbreviatedRelativeLocationPath.py", line 31
    as = ParsedAxisSpecifier.ParsedAxisSpecifier('descendant-or-self')
     ^
SyntaxError: invalid syntax

Looking it up led me to understand that this is because 'as' is a reserved name in python-2.6 and PyXML-0.8.4 tries to redefine it. However, there are no directions on how to resolve this issue.

Please advise.

Mindstorm
  • 443
  • 1
  • 5
  • 12
  • As you can see from the error, the usage of the 'as' keyword which violates its reservedness is in the PyXML library and not my code. So, I'm clueless as to how I can resolve this. PS - I am on my work system and am unable to make changes to the installed libraries. – Mindstorm Oct 22 '12 at 20:45
  • 1
    http://stackoverflow.com/questions/4953600/pyxml-on-ubuntu – Sheena Oct 22 '12 at 20:52
  • I wonder why this didn't come up in my initial search. Anyways, I now know better than to keep using PyXML :) Thanks Sheena! – Mindstorm Oct 22 '12 at 20:55

1 Answers1

3

PyXML is obsolete and should not be used (see here). That's why there are no updates for it. Many features that were included in it were added to Python's standard library. There are also fully-supported third-party packages for Python XML processing like lxml.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • I see. I was reading example code from a book to aid my learning. I guess I'll use these libraries for my purpose. Thank you so much Ned! – Mindstorm Oct 22 '12 at 20:49