【发布时间】:2013-08-14 12:22:18
【问题描述】:
我在 python 中完成了以下代码,以获取存储在 eXist-db 中的 XML 查询响应。我得到了值,但问题是下面的输出中给出的“即时”类型。这是我的代码:
from eulexistdb import db
class TestExist:
def __init__(self):
self.db = db.ExistDB("http://localhost:8899/exist/")
def get_res(self,query):
#result = list()
res = self.db.executeQuery(query)
hits = self.db.getHits(res)
for i in range(hits):
print self.db.retrieve(res,i)
print type(self.db.retrieve(res,i))
xquery = '''
let $x:= doc("/db/sample/books.xml")
return $x/bookstore/book/price/text()'''
a = TestExist()
a.get_res(xquery)
现在查询工作正常,结果也打印为:
30.00
<type 'instance'>
29.99
<type 'instance'>
49.99
<type 'instance'>
39.95
<type 'instance'>
我想要的是返回列表“结果”中附加的值。我尝试了类型转换但失败了。我如何做到这一点?
【问题讨论】:
-
你说,“我得到了价值,但问题是。”请编辑您的帖子以完成这句话。