basex [-bcdiLosuvVwxz] [query]


basex is a fast and powerful, yet light-weight and platform independent XML database system and XPath/XQuery processor.


A short description of option can be obtained from

    $ basex -h

or by browsing


A list of supported Database commands can be obtained from

    $ basex -c help

or by browsing


  • XQuery evaluation (no database, no interaction, script mode):

   $ basex -Lq 19+23
   $ basex -Lq "<answer>{ 23+19 }</answer>"

  • Import an XML file into database, output its content (query its root) and be verbose:

    $ basex -Vc "CREATE DB input /usr/share/doc/basex/examples/input.xml; XQUERY /"
    Database 'input' created in 136.84 ms.
      <!-- Header -->
      <head id="0">
      <!-- Body -->
      <body id="1" bgcolor="#FFFFFF" text="#000000" link="#0000CC">
        <h1>Databases & XML</h1>
        <div align="right">
            <li>Exercise 1</li>
            <li>Exercise 2</li>
      <?pi bogus?>

    Query: /


    Result: root()

    Parsing: 5.08 ms
    Compiling: 27.2 ms
    Evaluating: 0.87 ms
    Printing: 13.7 ms
    Total Time: 46.86 ms

    Hit(s): 1 Item
    Updated: 0 Items
    Printed: 358 Bytes

    Query executed in 42.52 ms.

  • XPath evaluation (with existing database):

    $ basex -Lc "OPEN input; XQUERY //li[1]"
    <li>Exercise 1</li>

  • Retrieve XML from the web and perform XPath query:

    $ basex -Lq "doc('')//li"
    <li>Exercise 1</li>
    <li>Exercise 2</li>

  • W3C XQuery Full-Text (make use of full-text index and perform fuzzy query with a typing error):

    $ basex
    BaseX 7.1 [Standalone]
    Try "help" to get more information.

    > SET FTINDEX on
    Full-Text Index: ON
    > CREATE DB input /usr/share/doc/basex/examples/input.xml
    Database 'input' created in 94.42 ms.
    > XQUERY //b[text() contains text 'Asisgnment' using fuzzy]
    Query executed in 8.37 ms.

  • Update the database and show result:

    > XQUERY delete node //ul
    Query executed in 2.79 ms.
    > XQUERY replace value of node //b with 'Debian rules'
    Query executed in 2.94 ms.
    > XQUERY //div
    <div align="right">
      <b>Debian rules</b>
    Query executed in 1.01 ms.

  • Open an input xml file, execute a query and write result into file:

    $ basex -Li /usr/share/doc/basex/examples/input.xml -q //div -o out.xml
    $ cat out.xml
    <div align="right">
        <li>Exercise 1</li>
        <li>Exercise 2</li>

  • Query an already existing database called 'input'. If a file named 'input' exists in current working directory it takes precedence:

    $ basex -Li input -q //div
    <div align="right">
        <li>Exercise 1</li>
        <li>Exercise 2</li>

  • Let basex process query input from standard in:

   $ echo '19+23' | basex -Lq-

  • Execute commands from script file:

   $ cat commands.txt
   create db debian <debian_db/>
   xquery /
   $ basex -LC commands.txt | grep debian
   debian              1          4639       debian.xml

  • Parse non well-formed HTML (needs libtagsoup-java installed):

   $ cat bad.html

   $ basex -c 'set parser html; set htmlopt method=html,nons=true; create db htmldb bad.html'
   $ basex -q "doc('htmldb')"

   For further documentation on how to configure the HTML Parser refer to


basexgui(1), basexserver(1), basexclient(1)

~/.basex BaseX (standalone and server) properties

~/.basexgui BaseX additional GUI properties

~/.basexperm user name, passwords, and permissions

~/.basexevents contains all existing events

~/BaseXData Default database directory

~/BaseXData/.logs Server logs

~/BaseXRepo Package repository

BaseX Documentation Wiki:


BaseX started as a research project of the Database and Information Systems Group (DBIS) at the University of Konstanz in 2005 and soon turned into a feature-rich open source XML database and XPath/XQuery processor.


New (3-clause) BSD License


BaseX is developed by a bunch of people called 'The BaseX Team' <> led by Christian Gruen <[email protected]>.

The man page was written by Alexander Holupirek <a[email protected]> while packaging BaseX for Debian GNU/Linux.