如何连接 python lxml 树
我正在使用他们创建的refreshbooks[1] python 脚本来处理freshbooks api。我限制每次调用 100 个结果,因此我尝试将一组调用放在一起,以将一个大的元素列表放在一起,以便与 jquery 数据表一起使用。我的问题是如何连接其中两个元素树?
这里有两个简单的调用,一次获取一个结果:
client_response = c.client.list(
per_page=1,
page=1
)
client_response2 = c.client.list(
per_page=1,
page=2
)
client_response.clients 中的基本响应如下所示:
<clients xmlns="http://www.freshbooks.com/api/" page="1" per_page="1" pages="2" total="2">
<client>...</client>
</clients>
我尝试将它们视为列表并使用 .extend 但没有运气。
更新:这些对象实际上是 lxml.objectify.ObjectifiedElement 对象,而不是真正的树,但我的问题仍然是如何连接这些...
I'm working with the freshbooks api using the refreshbooks[1] python script they've created. I'm limited to 100 results per call, so I was trying to put a group of calls together to put together a large list of elements to use with jquery datatables. My question is how do I concat two of these element trees?
Here are two simple calls that grab one result at a time:
client_response = c.client.list(
per_page=1,
page=1
)
client_response2 = c.client.list(
per_page=1,
page=2
)
And the basic response in client_response.clients looks like:
<clients xmlns="http://www.freshbooks.com/api/" page="1" per_page="1" pages="2" total="2">
<client>...</client>
</clients>
I've tried treating them as lists and using .extend but have had no luck.
Updated: the objects are actually lxml.objectify.ObjectifiedElement objects, not truly trees, but my question still stands on how to concat these...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够通过首先将项目转换为列表然后扩展来将这些项目连接到列表中:
I was able to concatenate these items into list by first converting the items to lists then extending: