Re: [bdbxml] Python & XmlModify
George Feinberg <[email protected]>
| Newsgroups | gmane.comp.db.dbxml.general |
|---|---|
| Message-ID | <[email protected]> |
On Jun 29, 2005, at 6:37 AM, TT wrote:
> XmlModify under Python 2.4 seems to be broken. I've used the newest
> 2.1.8 BDB
> XML, Visual Studio .Net 2003 and Python 2.4.1
>
> I cannot perform the execute() method on XmlModify object as it
> throws the
> RuntimeError, saying that I send a wrong XmlValue argument which is
> neither
> XmlModify.Node nor XmlModify.Element
> When I check the object which is an instance of XmlValue with
> getType() it
> yields 3 which is XmlModify.Node
>
> If you had luck with XmlModify under Python please attach some code.
This code works -- it's a slightly modified version of
example02 in examples/python/examples.py:
...
mgr = XmlManager()
uc = mgr.createUpdateContext()
container = mgr.createContainer("test.dbxml")
container.putDocument(book_name, book_content, uc)
qc = mgr.createQueryContext()
results = mgr.query("collection('test.dbxml')/book", qc)
mod = mgr.createModify()
exp = mgr.prepare("./title", qc)
mod.addInsertAfterStep(exp, XmlModify.Element, "new", "text")
results.reset()
for value in results:
mod.execute(value, qc, uc)
document = value.asDocument()
print document.getName(), "=", value.asString()
container.updateDocument(document, uc)
doc1 = container.getDocument(book_name)
print "after: ", document.getContent()
George
------------------------------------------
To remove yourself from this list, send an
email to [email protected]