【问题标题】:Berkeley XML DB "where" analogBerkeley XML DB "where" 类比
【发布时间】:2015-05-05 17:37:18
【问题描述】:

我目前正在学习 Berkeley XML DB,并获得了使用它编写 Python 脚本的任务。我目前面临的问题是选择容器的特定节点。例如,我们有包含此类信息的容器

<root>
  <lab>
    <name>Lab1</name>
    <state>Completed</state>
  </lab>
  <lab>
    <name>Lab3</name>
    <state>Not completed</state>
  </lab>
</root>

如何选择具有特定&lt;name&gt;&lt;lab&gt; 元素?在 SQL 中,我会使用 WHERE Name='Lab1'。有没有办法在 XML BDB 中做类似的事情?

【问题讨论】:

    标签: berkeley-db-xml


    【解决方案1】:

    我认为您最好获取旧文档、复制数据、删除文档并添加新的修改数据。

    mgr = XmlManager()
    uc = mgr.createUpdateContext()
    container = mgr.openContainer("labs.dbxml")  # Here must be your database name
    
    qc = mgr.createQueryContext()
    document = container.getDocument("Lab11")
    name = document.getName()
    content = document.getContent()
    
    # Change fields here using XPath
    
    container.deleteDocument('La1 1', uc)
    container.putDocument(name, content, uc)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多