<p>What are the libraries that support XPath? Is there a full implementation? How is the library used? Where is its website?</p>

[{'answer_id': 8699, 'author': 'James Sulak', 'author_id': 207, 'author_profile': 'https://Stackoverflow.com/users/207', 'pm_score': 6, 'selected': False, 'text': '<p>The <a href="http://lxml.de/" rel="noreferrer">lxml package</a> supports xpath.  It seems to work pretty well, although I\'ve had some trouble with the self:: axis.  There\'s also <a href="http://pypi.python.org/pypi/Amara/1.1.6" rel="noreferrer">Amara</a>, but I haven\'t used it personally.</p>\n'}, {'answer_id': 9171, 'author': 'David Joyner', 'author_id': 1146, 'author_profile': 'https://Stackoverflow.com/users/1146', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://pyxml.sourceforge.net" rel="nofollow noreferrer" title="PyXML">PyXML</a> works well.  </p>\n\n<p>You didn\'t say what platform you\'re using, however if you\'re on Ubuntu you can get it with <code>sudo apt-get install python-xml</code>.  I\'m sure other Linux distros have it as well.  </p>\n\n<p>If you\'re on a Mac, xpath is already installed but not immediately accessible.  You can set <code>PY_USE_XMLPLUS</code> in your environment or do it the Python way before you import xml.xpath:</p>\n\n<pre><code>if sys.platform.startswith(\'darwin\'):\n    os.environ[\'PY_USE_XMLPLUS\'] = \'1\'\n</code></pre>\n\n<p>In the worst case you may have to build it yourself.  This package is no longer maintained but still builds fine and works with modern 2.x Pythons.  Basic docs are <a href="http://pyxml.sourceforge.net/topics/howto/section-XPath.html" rel="nofollow noreferrer">here</a>.</p>\n'}, {'answer_id': 10846, 'author': 'jkp', 'author_id': 912, 'author_profile': 'https://Stackoverflow.com/users/912', 'pm_score': 3, 'selected': False, 'text': '<p>The latest version of <a href="http://effbot.org/zone/element-xpath.htm" rel="noreferrer">elementtree</a> supports XPath pretty well.  Not being an XPath expert I can\'t say for sure if the implementation is full but it has satisfied most of my needs when working in Python.  I\'ve also use lxml and PyXML and I find etree nice because it\'s a standard module.</p>\n\n<p>NOTE: I\'ve since found lxml and for me it\'s definitely the best XML lib out there for Python.  It does XPath nicely as well (though again perhaps not a full implementation).</p>\n'}, {'answer_id': 27974, 'author': 'Ryan Cox', 'author_id': 620, 'author_profile': 'https://Stackoverflow.com/users/620', 'pm_score': 7, 'selected': False, 'text': '<p><a href="http://xmlsoft.org/python.html" rel="noreferrer">libxml2</a> has a number of advantages:</p>\n\n<ol>\n<li>Compliance to the <a href="http://www.w3.org/TR/xpath" rel="noreferrer">spec</a></li>\n<li>Active development and a community participation </li>\n<li>Speed. This is really a python wrapper around a C implementation. </li>\n<li>Ubiquity. The libxml2 library is pervasive and thus well tested.</li>\n</ol>\n\n<p>Downsides include:</p>\n\n<ol>\n<li>Compliance to the <a href="http://www.w3.org/TR/xpath" rel="noreferrer">spec</a>. It\'s strict. Things like default namespace handling are easier in other libraries.</li>\n<li>Use of native code. This can be a pain depending on your how your application is distributed / deployed. RPMs are available that ease some of this pain.</li>\n<li>Manual resource handling. Note in the sample below the calls to freeDoc() and xpathFreeContext(). This is not very Pythonic.</li>\n</ol>\n\n<p>If you are doing simple path selection, stick with <a href="http://effbot.org/zone/element-xpath.htm" rel="noreferrer">ElementTree</a> ( which is included in Python 2.5 ). If you need full spec compliance or raw speed and can cope with the distribution of native code, go with libxml2.</p>\n\n<p><strong>Sample of libxml2 XPath Use</strong></p>\n\n<hr>\n\n<pre><code>import libxml2\n\ndoc = libxml2.parseFile("tst.xml")\nctxt = doc.xpathNewContext()\nres = ctxt.xpathEval("//*")\nif len(res) != 2:\n    print "xpath query: wrong node set size"\n    sys.exit(1)\nif res[0].name != "doc" or res[1].name != "foo":\n    print "xpath query: wrong node set value"\n    sys.exit(1)\ndoc.freeDoc()\nctxt.xpathFreeContext()\n</code></pre>\n\n<p><strong>Sample of ElementTree XPath Use</strong></p>\n\n<hr>\n\n<pre><code>from elementtree.ElementTree import ElementTree\nmydoc = ElementTree(file=\'tst.xml\')\nfor e in mydoc.findall(\'/foo/bar\'):\n    print e.get(\'title\').text</code></pre>\n\n<hr>\n'}, {'answer_id': 1732475, 'author': 'user210794', 'author_id': 210794, 'author_profile': 'https://Stackoverflow.com/users/210794', 'pm_score': 5, 'selected': False, 'text': '<p>Use LXML. LXML uses the full power of libxml2 and libxslt, but wraps them in more "Pythonic" bindings than the Python bindings that are native to those libraries. As such, it gets the full XPath 1.0 implementation. Native ElemenTree supports a limited subset of XPath, although it may be good enough for your needs.</p>\n'}, {'answer_id': 2122709, 'author': 'Sam', 'author_id': 37575, 'author_profile': 'https://Stackoverflow.com/users/37575', 'pm_score': 5, 'selected': False, 'text': '<p>Another option is <a href="http://code.google.com/p/py-dom-xpath/" rel="noreferrer">py-dom-xpath</a>, it works seamlessly with minidom and is pure Python so works on appengine.</p>\n\n<pre><code>import xpath\nxpath.find(\'//item\', doc)\n</code></pre>\n'}, {'answer_id': 3547727, 'author': 'codeape', 'author_id': 3571, 'author_profile': 'https://Stackoverflow.com/users/3571', 'pm_score': 2, 'selected': False, 'text': '<p>Another library is 4Suite: <a href="http://sourceforge.net/projects/foursuite/" rel="nofollow noreferrer">http://sourceforge.net/projects/foursuite/</a></p>\n\n<p>I do not know how spec-compliant it is. But it has worked very well for my use. It looks abandoned.</p>\n'}, {'answer_id': 3547741, 'author': '0xAX', 'author_id': 274299, 'author_profile': 'https://Stackoverflow.com/users/274299', 'pm_score': 4, 'selected': False, 'text': "<p>You can use:</p>\n\n<p><strong>PyXML</strong>:</p>\n\n<pre><code>from xml.dom.ext.reader import Sax2\nfrom xml import xpath\ndoc = Sax2.FromXmlFile('foo.xml').documentElement\nfor url in xpath.Evaluate('//@Url', doc):\n  print url.value\n</code></pre>\n\n<p><strong>libxml2</strong>:</p>\n\n<pre><code>import libxml2\ndoc = libxml2.parseFile('foo.xml')\nfor url in doc.xpathEval('//@Url'):\n  print url.content\n</code></pre>\n"}, {'answer_id': 13504511, 'author': 'Gringo Suave', 'author_id': 450917, 'author_profile': 'https://Stackoverflow.com/users/450917', 'pm_score': 6, 'selected': False, 'text': '<p>Sounds like an lxml advertisement in here. ;)  ElementTree is included in the std library.  Under 2.6 and below its xpath is pretty weak, but in 2.7+ and 3.x <a href="http://docs.python.org/3/library/xml.etree.elementtree.html#xpath-support" rel="nofollow noreferrer">much improved</a>:</p>\n<pre class="lang-py prettyprint-override"><code>import xml.etree.ElementTree as ET\n\nroot = ET.parse(filename)\nresult = \'\'\n\nfor elem in root.findall(\'.//child/grandchild\'):\n    # How to make decisions based on attributes:\n    if elem.attrib.get(\'name\') == \'foo\':\n        result = elem.text\n        break\n</code></pre>\n'}, {'answer_id': 33716764, 'author': 'Aminah Nuraini', 'author_id': 1564659, 'author_profile': 'https://Stackoverflow.com/users/1564659', 'pm_score': 3, 'selected': False, 'text': '<p>You can use the simple <code>soupparser</code> from <code>lxml</code></p>\n\n<h2>Example:</h2>\n\n<pre><code>from lxml.html.soupparser import fromstring\n\ntree = fromstring("&lt;a&gt;Find me!&lt;/a&gt;")\nprint tree.xpath("//a/text()")\n</code></pre>\n'}, {'answer_id': 47850440, 'author': 'eLRuLL', 'author_id': 858913, 'author_profile': 'https://Stackoverflow.com/users/858913', 'pm_score': 3, 'selected': False, 'text': '<p>If you want to have the power of XPATH combined with the ability to also use CSS at any point you can use <a href="https://github.com/scrapy/parsel" rel="noreferrer"><code>parsel</code></a>:</p>\n\n<pre><code>&gt;&gt;&gt; from parsel import Selector\n&gt;&gt;&gt; sel = Selector(text=u"""&lt;html&gt;\n        &lt;body&gt;\n            &lt;h1&gt;Hello, Parsel!&lt;/h1&gt;\n            &lt;ul&gt;\n                &lt;li&gt;&lt;a href="http://example.com"&gt;Link 1&lt;/a&gt;&lt;/li&gt;\n                &lt;li&gt;&lt;a href="http://scrapy.org"&gt;Link 2&lt;/a&gt;&lt;/li&gt;\n            &lt;/ul\n        &lt;/body&gt;\n        &lt;/html&gt;""")\n&gt;&gt;&gt;\n&gt;&gt;&gt; sel.css(\'h1::text\').extract_first()\n\'Hello, Parsel!\'\n&gt;&gt;&gt; sel.xpath(\'//h1/text()\').extract_first()\n\'Hello, Parsel!\'\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/8692', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']