主要提供lxml的zope3接口定义
项目描述
此软件包提供lxml对象的zope接口。远非完整,但是一个起点。
接口
接口在这里
>>> import gocept.lxml.interfaces
有一个用于lxml.etree元素的接口
>>> import lxml.etree >>> xml = lxml.etree.fromstring('<a/>') >>> gocept.lxml.interfaces.IElement.providedBy(xml) True
以及对象化的接口
>>> 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
对象化解析器
在gocept.lxml.objectify中有用于从文件句柄创建对象化的辅助函数。打开一个文件
>>> import os.path >>> import gocept.lxml.objectify >>> filename = os.path.join( ... os.path.dirname(__file__), ... 'ftesting.zcml') >>> xml_file = file(filename)
然后解析它
>>> xml = gocept.lxml.objectify.fromfile(xml_file) >>> xml <Element {http://namespaces.zope.org/zope}configure at ...>
这真的是对象化的
>>> gocept.lxml.interfaces.IObjectified.providedBy(xml) True >>> xml.include.get('package') 'zope.app.component'
为了方便,fromstring也在gocept.lxml.objectify中定义
>>> xml = gocept.lxml.objectify.fromstring('<a><b/></a>') >>> xml <Element a at ...> >>> gocept.lxml.interfaces.IObjectified.providedBy(xml) True
变更
0.2.1 (2008-02-14)
移除了对lxml<2.0dev的依赖,现在可以使用lxml 2了。
项目详情
关闭
gocept.lxml-0.2.1.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 017f6465260e07441c30a7a74e8bb663ded54faab8eae05fa17384ec14962c36 |
|
MD5 | 0480242b7c84f2e8e1d42741c2800197 |
|
BLAKE2b-256 | 9e759953d6a87b99bc140b7dbd970eddf4f94f3cfc06d8efa1a04026a6480948 |