我在 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'>
我想要的是返回列表“结果”中附加的值。我尝试了类型转换但失败了。我如何实现这一目标?