> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/x/xml-file-source-codes.md).

# XML File Source Codes

XML File Source Codes reads an XML file that you copy to the connector host. Each element named by **Record Tag** becomes one repository record. Child elements and attributes become fields. OctoXLabs uses it to add source codes (repositories) that no other adapter can reach.

## Use cases

* Import source codes (repositories) from an XML export of a system that has no adapter. List everything this adapter imported:

```
Adapters = xml-file-source-codes
```

* Show only the records of one connection. Replace the name with the name you gave the connection.

```
Connections = YOUR_CONNECTION_NAME
```

## Before you begin

### Network

| Source              | Destination                             | Port           | Protocol       |
| ------------------- | --------------------------------------- | -------------- | -------------- |
| OctoXLabs connector | Local file system of the connector host | Not applicable | Not applicable |

This adapter makes no network calls.

### Required permissions

| Scope or role                                     | Permission | Needed for   |
| ------------------------------------------------- | ---------- | ------------ |
| File system, `/opt/octoxlabs/connector/media/xml` | Read       | The XML file |

The file path is resolved inside this folder. An absolute path or a `..` segment in **Filename** is rejected.

## Create credentials in XML File Source Codes

This adapter needs no credentials. Prepare and place the file instead.

{% stepper %}
{% step %}

### Prepare the file

Create an XML file where each repository is one element, for example `<repository>`. Name its child elements with the field names from the fields table below so records map on their own.
{% endstep %}

{% step %}

### Copy the file

Copy the file to `/opt/octoxlabs/connector/media/xml` on the connector host.
{% endstep %}

{% step %}

### Check the permissions

Make sure the connector process can read the file.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter         | Required | Type | Default    | Description                                                                                                                    |
| ----------------- | -------- | ---- | ---------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Filename          | Yes      | Text |            | Name of the file in `/opt/octoxlabs/connector/media/xml`. A pattern such as `sourcecodes*.xml` reads the newest matching file. |
| Record Tag        | No       | Text | repository | XML tag that represents one record.                                                                                            |
| Primary Key Field | No       | Text | PrimaryKey | Tag that holds the unique ID of each record. Dotted paths work for nested values, for example `meta.id`.                       |

## Troubleshooting

| Error message                                                                 | Cause                                                                                 | Fix                                                                                    |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| File not found with this pattern.                                             | No file matches **Filename** in the media folder, or the match is outside the folder. | Check the name and the pattern. Copy the file to `/opt/octoxlabs/connector/media/xml`. |
| An absolute path is not allowed; give a name relative to the adapter's folder | **Filename** is an absolute path.                                                     | Enter a name relative to the folder.                                                   |

## Change history
