Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install gocept.lxml

How to install gocept.lxml

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install gocept.lxml
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.2.1 Available View build log
Windows (64-bit)
0.2.1 Available View build log
Mac OS X (10.5+)
0.2.1 Available View build log
Linux (32-bit)
0.2.1 Available View build log
Linux (64-bit)
0.2.1 Available View build log
 
License
ZPL 2.1
Imports
Lastest release
version 0.2.1 on Jan 5th, 2011

This package provides zope interfaces for lxml objects. Far from being complete but a starting point.

Interfaces

Interfaces are here:

>>> import gocept.lxml.interfaces

There is an interface for lxml.etree elements:

>>> import lxml.etree
>>> xml = lxml.etree.fromstring('<a/>')
>>> gocept.lxml.interfaces.IElement.providedBy(xml)
True

And for objectifieds:

>>> import lxml.objectify
>>> obj = lxml.objectify.fromstring('<a><str>holla</str></a>')
>>> gocept.lxml.interfaces.IElement.providedBy(obj)
True
>>> gocept.lxml.interfaces.IObjectified.providedBy(obj)
True
>>> gocept.lxml.interfaces.IElement.providedBy(obj.str)
True
>>> gocept.lxml.interfaces.IObjectified.providedBy(obj.str)
True

Objectified parsers

There is a helper for creating objectifieds from file handles in gocept.lxml.objectify. Open a file:

>>> import os.path
>>> import gocept.lxml.objectify
>>> filename = os.path.join(
...     os.path.dirname(__file__),
...     'ftesting.zcml')
>>> xml_file = file(filename)

And parse it:

>>> xml = gocept.lxml.objectify.fromfile(xml_file)
>>> xml
<Element {http://namespaces.zope.org/zope}configure at ...>

This really is objectified:

>>> gocept.lxml.interfaces.IObjectified.providedBy(xml)
True
>>> xml.include.get('package')
'zope.app.component'

For convinience fromstring is also defined in gocept.lxml.objectify:

>>> xml = gocept.lxml.objectify.fromstring('<a><b/></a>')
>>> xml
<Element a at ...>
>>> gocept.lxml.interfaces.IObjectified.providedBy(xml)
True

Changes

0.2.1 (2008-02-14)
  • Lifted dependency on lxml<2.0dev so lxml 2 can be used now.

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.