【发布时间】:2014-06-30 09:40:01
【问题描述】:
我有一个xsd,我使用pyxb 为其生成对象类。到目前为止,一切正常,我能够接收文档,错误处理等工作正常。我唯一的问题是,我的 xsd 中有以下内容:
<xs:element name="users">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="user" />
</xs:sequence>
</xs:complexType>
</xs:element>
我在别处定义了user 复杂类型。有时我想从主 xml 文档中获取user,我想从中创建 python 类绑定......但我做不到。 pyxb 只允许我从整个文档创建(使用 CreateFromDocument 函数)。有没有办法只得到一个user 元素?
我读到以下内容:
https://developer.yahoo.com/python/python-xml.html
http://pyxb.sourceforge.net/api/pyxb.binding.basis.element-class.html
【问题讨论】:
标签: python xml-parsing xsd pyxb