Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7539943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:30:54+00:00 2026-05-30T07:30:54+00:00

I am storing two XML documents, namely hospital and office, in BaseX. The following

  • 0

I am storing two XML documents, namely hospital and office, in BaseX.

The following is the office xml:

<Staff>
    <Employee Name="Brian">
        <Personal>
            <SSN> 666-66-6666 </SSN>
        </Personal>
        <StaffInfo>
            <Position> Doctor </Position>
            <AccountableTo> David </AccountableTo>
        </StaffInfo>
    </Employee>
    <Employee Name="David">
        <Personal>
            <SSN> 555-55-5555 </SSN>
        </Personal>
        <StaffInfo>
            <Position> Doctor </Position>
            <AccountableTo />
        </StaffInfo>
    </Employee>
</Staff>

In this XML I want to add one or more employees. How can I add elements using BaseX?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:30:55+00:00Added an answer on May 30, 2026 at 7:30 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement to compare two XML documents and report differences. String comparison
I have two models in my Django application, for the purposes of storing search
I've two routes, 1) creating sub-tables for each user and storing his individual content
In Zend Framework in Response Class there are two different arrays for storing headers:
I was thinking that I would have two tables for mysql. One for storing
In my app, I'm storing Bitmap data in a two-dimensional integer array ( int[,]
I inherited an XML license file containing no root element, but rather two XML
I have a set of XML documents that all share the same schema. (They're
I have a simple XML document containing two city id's. <?xml version=1.0 encoding=ISO-8859-1?> <config>
I want to deserialise an xml document with a number of same name nodes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.