---
updatedAt: 2026-09-28T14:53:24.000Z
agentTools:
  projectIndex: https://developer.searchblox.com/llms.txt
---

# XML DB Connector

Setting up XML DB Connector

## **Create a Database Collection in SearchBlox**

* **Access Collection Creation**\
  Log in to the SearchBlox Admin Console\
  Go to the Collections tab\
  Click either:\
  Create a New Collection button, or\
  The "+" (plus) icon in the collections panel
* **Configure Collection Type**\
  Choose "Database Collection" from the list\
  This allows the system to connect with XML databases
* Define Collection Properties\
  **Collection Name:** Enter a unique name (example: XML\_Products)\
  **Access Control:**\
  Choose:\
  Private – only selected users can access\
  Public – everyone can access\
  \*\* Security: **Enable/disable depending on how sensitive the data is\
  \*\* Language:**\
  Default is English\
  Select another language if your content is in a different language
* **Finalize Creation**\
  Click Save to create the collection\
  A confirmation message will appear after successful creation

![](https://files.readme.io/003e388012847afd02d99f0919e956d80cbbab0ef992278a195e42243dd3baf3-image.png)

## **XMLSample Data**

The sample XML file is used to set up SQL queries and database connection URLs.

Steps to Test the DB Connector:

Download the XML file.

Save it in the required folder.

Follow the given instructions to check whether the DB connector is working properly.

```xml personal.xml
<?xml version="1.0" encoding="UTF-8" ?>
<root>
  <rootAttr1>rootValue1</rootAttr1>
  <people>
    <personal>
      <age>20</age>
      <gender>M</gender>
      <name>
        <first>John</first>
        <last>Doe</last>
      </name>
    </personal>
    <jobs>support</jobs>
    <jobs>coding</jobs>
    <vehicles>
      <type>car</type>
      <model>Honda Civic</model>
      <insurance>
        <company>ABC Insurance</company>
        <policy_num>12345</policy_num>
      </insurance>
      <features>sunroof</features>
      <features>rims</features>
      <maintenance>
        <date>07-17-2017</date>
        <desc>oil change</desc>
      </maintenance>
      <maintenance>
        <date>01-03-2018</date>
        <desc>new tires</desc>
      </maintenance>
    </vehicles>
    <vehicles>
      <type>truck</type>
      <model>Dodge Ram</model>
      <insurance>
        <company>ABC Insurance</company>
        <policy_num>12345</policy_num>
      </insurance>
      <features>lift kit</features>
      <features>tow package</features>
      <maintenance>
        <date>08-27-2017</date>
        <desc>new tires</desc>
      </maintenance>
      <maintenance>
        <date>01-08-2018</date>
        <desc>oil change</desc>
      </maintenance>
    </vehicles>
    <addresses>
      <type>work</type>
      <zip>12345</zip>
    </addresses>
    <addresses>
      <type>home</type>
      <zip>12357</zip>
    </addresses>
    <source>internet</source>
  </people>
  <people>
    <personal>
      <age>24</age>
      <gender>F</gender>
      <name>
        <first>Jane</first>
        <last>Roberts</last>
      </name>
    </personal>
    <jobs>sales</jobs>
    <jobs>marketing</jobs>
    <source>phone</source>
    <vehicles>
      <type>car</type>
      <model>Toyota Camry</model>
      <insurance>
        <company>Car Insurance</company>
        <policy_num>98765</policy_num>
      </insurance>
      <features>upgraded stereo</features>
      <maintenance>
        <date>05-11-2017</date>
        <desc>tires rotated</desc>
      </maintenance>
      <maintenance>
        <date>11-03-2017</date>
        <desc>oil change</desc>
      </maintenance>
    </vehicles>
    <vehicles>
      <type>car</type>
      <model>Honda Accord</model>
      <insurance>
        <company>Car Insurance</company>
        <policy_num>98765</policy_num>
      </insurance>
      <features>custom paint</features>
      <features>custom wheels</features>
      <maintenance>
        <date>10-07-2017</date>
        <desc>new air filter</desc>
      </maintenance>
      <maintenance>
        <date>01-13-2018</date>
        <desc>new brakes</desc>
      </maintenance>
    </vehicles>
    <addresses>
      <type>home</type>
      <zip>98765</zip>
    </addresses>
    <addresses>
      <type>work</type>
      <zip>98753</zip>
    </addresses>
  </people>
  <rootAttr2>rootValue2</rootAttr2>
  <rootAttr3>rootValue3</rootAttr3>
  <rootAttr3>rootValue4</rootAttr3>
</root>
```

* The main element in this XML file is people.
* The structure of objects in the file is represented in the following table.\
  [Learn more on Parsing XML Data](https://cdn.cdata.com/help/DVG/jdbc/pg_xmldatabase.htm)

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/8161f30-jsonrawdatastructure.png",
        "jsonrawdatastructure.png",
        569
      ],
      "align": "center",
      "caption": "**JSON Objects in the file**"
    }
  ]
}
[/block]

## **Database Collection Settings**

Essential Configuration Parameters

* Database Type Selection\
  Step: Open the Database Type dropdown menu\
  Action: Select "XML" as the database type\
  Purpose: This allows the system to properly read, process, and index XML data
* Select XML as the database type from the dropdown menu.
* Enter the Database URL String in the required format (as shown in the example).
* ```
  jdbc:xml:DataModel=Relational;URI=file_path.xml
  ```
* Enter the exact URI (path or location) of your XML file.
* Enter the SQL query that will read the data from the XML file and store it.
* ```Text sql
  SELECT * FROM xml_document
  ```

![](https://files.readme.io/d32d3cf297745bf8aaa81713275c8dfeb5cceb0e1f17ce8dc101156ae1d2be51-image.png)

* Click Save to store your settings.
* Click Test Database Collection to verify the setup.\
  The database connection must be successful for indexing to work properly.

> 📘 Configure SQL Query
>
> * To get data from the XML file, you must provide a SELECT SQL query.
> * You must map a unique field to uid (this is required).
> * The query should follow SQL SELECT query format with mappings. [SQL Query for Database Collection](https://developer.searchblox.com/docs/sql-query-for-db-collection)
>   ```
>   SELECT <index field> as uid , <column name2> as title, <column name3> as content FROM <tablename> LIMIT 100
>   ```
>   <br />
> * n the above query, the fields are shown using a hierarchical structure for example:
>   ```
>   [people].[personal.name.first]
>   [people].[vehicles.maintenance.date]
>   ```
>
> [Reference for select queries for Database XML Connector](https://cdn.cdata.com/help/DVG/jdbc/pg_systemtablesintro.htm)
>
> * If your table has more than 100 records, use the LIMIT option in your query to control how many documents are indexed.\
>   Example:
>   ```
>   SELECT <index field> as uid , <column name2> as title, <column name3> as content FROM <tablename> LIMIT 100
>   ```
>   Otherwise, a minimum of 50 rows will be indexed.

![](https://files.readme.io/bae5fc0a262b5c319276beb5a8705edbf8515ead8a8d1518889f186837f18b2f-image.png)

## **Schedule and Index**

This setting lets you choose when and how often a collection should be indexed.

Schedule Frequency options available in SearchBlox:

Once

Hourly

Daily

Every 48 Hours

Every 96 Hours

Weekly

Monthly

The following actions are available for Database Collections:

| Action       | Description                                                                    |
| :----------- | :----------------------------------------------------------------------------- |
| **Schedule** | You can set up automatic indexing for each collection using the options above. |

To know more about Database Collection refer [Database Collection](https://developer.searchblox.com/docs/database-collection)

![](https://files.readme.io/09d33ecef534625bedb27b918352383279287693dec8d889a369e49d2e2f964b-image.png)

Search results in faceted search is shown here:

![](https://files.readme.io/e4d8944-jsonresultJSON.png "jsonresultJSON.png")

![](https://files.readme.io/eacd70c-xmlsearch.png "xmlsearch.png")

![](https://files.readme.io/0f892cf-XML_5.jpg "XML 5.jpg")