OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.2.2

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.2.2
    iconOceanBase Database
    SQL - V 4.2.2
    SQL
    KV
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    XML data definition

    Last Updated:2026-04-15 08:27:15  Updated
    share
    What is on this page
    XML syntax
    XPath
    Location steps
    Axes
    Node tests
    Predicates
    Wildcards
    Operators
    Function expressions

    folded

    share

    XML syntax

    The current version of OceanBase Database supports the XML 1.0 syntax, but does not support XML schemas or Document Type Definitions (DTDs). An XML document is mainly composed of two parts: the XML declaration and document content. The document content usually contains elements, attributes, comments, escape characters, and processing instructions.

    An XML declaration has a fixed structure, such as <?xml version="1.0"?>. The XML document content has only one root element, which can contain any number of child elements. An element can contain attributes. For example, <book isbn="123-456-789">...<title>mybook</title><author>Alex</author></book> contains the isbn="123-456-789" attribute and two child elements: <title> and <author>. Child elements must be nested correctly. An empty element, such as <tag></tag>, can be represented by an empty-element tag, such as <tag/>.

    An XML document uses identifiers, such as brackets (<>) and quotation marks (' or "). If the document content contains such special characters, you need to use &???; to escape them. For example, Java<tm> as the content of the child element name is escaped to <name>Java&lt;tm&gt;</name>. The following table lists the built-in escape characters in XML 1.0.

    Before escaping After escaping
    < &lt;
    > &gt;
    & &amp;
    " &quot;
    ' &apos;

    In an XML document, you can use the following syntax to define namespaces to avoid naming conflicts:

    xmlns:namespace-prefix="namespaceURI"
    

    The following sample XML document contains two table elements. Since the elements have different definitions, they must be distinguished by using namespaces. "http://www.example1.org/TR/html4/" and "http://www.example2.com.cn/furniture" are URLs that are used only as the unique names of the namespaces.

    <doc>
      <h:table xmlns:h="http://www.example1.org/TR/html4/">
        <h:tr>
          <h:td>Apples</h:td>
          <h:td>Bananas</h:td>
        </h:tr>
      </h:table>
      <f:table xmlns:f="http://www.example2.com.cn/furniture">
        <f:name>African Coffee Table</f:name>
        <f:width>80</f:width>
        <f:length>120</f:length>
      </f:table>
    </doc>
    

    Note that when a namespace is defined in the start tag of an element, all child elements with the same prefix are associated with this namespace.

    XPath

    XML Path Language (XPath) is a language used to locate specific elements in an XML document. You can use XPath in EXTRACT, UPDATEXML, and other XML functions.

    An XML document itself can be viewed as a node tree that contains element nodes, attribute nodes, and text nodes. XPath allows you to locate nodes in the data structure tree. XPath query results can be node sets (unordered collections without duplicate nodes), Boolean values (True or False), numbers, or strings.

    The following sample code shows the complete XPath syntax. Different location nodes in an XPath is separated by /. You can omit / for the first node.

    /axis::nodetest()  
    

    Here is an example:

    /descendant::a, /child::text()
    

    Parameters in the preceding example are described as follows:

    • descendant-or-self::para selects the para elements of the current node and all its descendants.

    • self::para selects the para element of the current node. If the current node does not have the para element, NULL is returned.

    • child::*/child::para selects all para grandchildren of the current node.

    • / selects the root node.

    Location steps

    XPath uses location steps to select nodes in an XML document.

    The following table describes the location steps supported by OceanBase Database.

    Abbreviated syntax for location step Description
    nodename Selects all children of only this node.
    / Selects from the root node.
    // Selects nodes in the document from the current node that match the selection no matter where they are.
    . Selects the current node.
    .. Selects the parent of the current node.
    @ Selects attributes.

    Axes

    An axis tells the XPath processor which direction to head from the current node.

    The following table describes the axes supported by OceanBase Database. Among them, child is the default axis.

    Axis Description
    ancestor Selects all ancestors (parent, grandparent, and so on) of the current node.
    ancestor-or-self Selects all ancestors (parent, grandparent, and so on) of the current node and the current node itself.
    attribute Selects all attributes of the current node.
    child Selects all element children of the current node.
    descendant Selects all descendants (children, grandchildren, and so on) of the current node.
    descendant-or-self Selects all descendants (children, grandchildren, and so on) of the current node and the current node itself.
    namespace Selects all namespace nodes of the current node.
    parent Selects the parent of the current node.
    self Selects the current node.

    Note

    The current version of OceanBase Database does not support the following-sibling, following, preceding, or preceding-sibling axis.

    The following table provides examples of axes.

    Example Description
    child::book Selects all book nodes that are children of the current node.
    attribute::lang Selects the lang attribute of the current node.
    child::* Selects all element children of the current node.
    attribute::* Selects all attributes of the current node.
    child::text() Selects all text node children of the current node.
    child::node() Selects all children of the current node.
    descendant::book Selects all book descendants of the current node.
    ancestor::book Selects all book ancestors of the current node.
    ancestor-or-self::book Selects all book ancestors of the current node and itself if it is a book node.
    child::*/child::price Selects all price grandchildren of the current node.

    Node tests

    A node test is used together with an axis to tell the XPath processor which nodes need to be selected. By default, element nodes are selected.

    The following table describes the node tests supported by OceanBase Database.

    Node test Description
    para_name Selects the node with the specified name. If the axis is attribute, this node test specifies an attribute name. If the axis is namespace, this node test specifies a namespace name. For other axes, this node test specifies an element name.
    text() Selects text nodes (without specifying the name).
    node() Selects all types of nodes (without specifying the name).
    comment() Selects comment nodes (without specifying the name).
    processing-instruction(literal) Selects pi nodes. When literal is not specified, the node test matches all pi nodes. Otherwise, it matches only the pi node of the specified name.

    Predicates

    A predicate tells the XPath processor to select a specific node or a node that contains a specific value.

    The following table provides some examples of predicates supported by OceanBase Database.

    Path expression Description
    //title[@lang='eng'] Selects all title elements whose lang attribute is eng.
    /bookstore/book[price>35.00] Selects all book elements whose price is greater than 35.00 in the bookstore element.
    /bookstore/book[price>35.00]/title Select all title elements of the book element whose price is greater than 35.00 in the bookstore element.

    Wildcards

    An XPath wildcard allows you to select any XML element.

    The following table describes the wildcards supported by OceanBase Database.

    Wildcard Description
    * Matches any element node.
    @* Matches any attribute node.
    node() Matches any type of node.
    text() Matches any text node.

    The following table provides examples of wildcards.

    Path expression Description
    /bookstore/* Selects all element children of the bookstore element.
    //* Selects all elements in the document.
    //title[@* = "attribute"] Selects all title elements with attributes.

    Operators

    The following table describes the operators supported for XPaths in OceanBase Database.

    Operator Description Example Return value
    = Equal price=9.80 If price is 9.80, true is returned. Otherwise, false is returned.
    != Not equal price!=9.80 If price is not 9.80, true is returned. Otherwise, false is returned.
    < Less than price<9.80 If price is less than 9.80, true is returned. Otherwise, false is returned.
    <= Less than or equal to price<=9.80 If price is less than or equal to 9.80, true is returned. Otherwise, false is returned.
    > Greater than price>9.80 If price is greater than 9.80, true is returned. Otherwise, false is returned.
    >= Greater than or equal to price>=9.80 If price is greater than or equal to 9.80, true is returned. Otherwise, false is returned.
    or Or price=9.80 or price=9.70 If price is 9.80 or 9.70, true is returned. Otherwise, false is returned.
    and And price>9.00 and price<9.90 If price is greater than 9.00 and less than 9.90, true is returned. Otherwise, false is returned.

    Function expressions

    The following table describes the function expressions supported for XPath definitions in the current version of OceanBase Database.

    Category Function expression Description
    Boolean boolean true() Returns TRUE.
    boolean false() Returns FALSE.

    Previous topic

    Overview
    Last

    Next topic

    Create an XMLType column
    Next
    What is on this page
    XML syntax
    XPath
    Location steps
    Axes
    Node tests
    Predicates
    Wildcards
    Operators
    Function expressions