Insertion of an data in an XML using Basex

安稳与你 提交于 2019-12-05 07:19:10

XQuery has an update facility, an official W3C recommendation, called XQuery Update to change the document structure.

You can use updates like so:

Given you have created a database employees, with the commmand:

CREATE DB office /path/to/office.xml

Now you may use the XQuery Update facility and run the following query:

let $up := <Employee Name="Joe">
    <Personal>
      <SSN>666-66-1234</SSN>
    </Personal>
    <StaffInfo>
      <Position>Doctor</Position>
      <AccountableTo>Jeff</AccountableTo>
    </StaffInfo>
  </Employee>

  return
insert node $up as last into doc('office')/Staff

This will ad the node referenced by $up at the last position in your database staff

The BaseX Documentation Wiki contains more information on updates:

There is a good tutorial, XQuery Update for the impatient provided by xmlmind.com.

Sure enough you can use the APIs to issue these queries, for a start I'd suggest you stick with GUI, so you can see results directly.

Hope this helped, feel free to ask for more information; either here or on the official BaseX Mailing List.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!