# XML

## Introduction

The XML Storage Action allows users to perform structured data transformations between systems using XML. It supports both parsing existing XML files and composing new XML documents based on user-defined templates and data streams.  This action allows users to define a structured schema for reading from or writing to external systems (like Salesforce, FTP servers, or CRMs). This ensures accurate parsing and mapping of data during transfer processes.

## **Steps to Configure the XML Action**

#### **Step 1: Select Operation**

1. Choose whether the action is to:

* **Read** from a source and convert to XML
* **Write** from XML to a destination

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FLPOZ8cdhjBtQTve2q2aF%2Fimage%20(24).png?alt=media&#x26;token=9bb67691-fa4e-49c3-a499-1dfe731c07f2" alt=""><figcaption></figcaption></figure>

#### **Step 2: Define File Structure**

2. Navigate to the **Compose** tab.
3. Use dynamic values. For example, you can use values like a **DateTime field** in the file name.
4. Proceed to **Configure XML**.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FIXPeATtbM6SE6F07HzJ0%2Fimage%20(25).png?alt=media&#x26;token=be67c22e-3741-436b-a7c6-a167f76f47b1" alt=""><figcaption></figcaption></figure>

#### **Step 3: Generate XML Structure**

5. Use a **sample file** from your source data and convert it into a XML structure.
6. Ensure the XML includes field names and nested tags as per the source (e.g., Salesforce fields).

Example:

```xml
<Opportunity>
  <Name>Acme Inc</Name>
  <Stage>Prospecting</Stage>
  <Amount>5000</Amount>
  <CloseDate>2025-06-09</CloseDate>
</Opportunity>
```

#### **Step 4: Test the XML Configuration**

7. Click on **Test** to validate the schema.
8. The output preview will show how the data appears.

#### **Step 5: Save to FTP**

9. Set the destination FTP file path.
10. The system will now write the parsed Salesforce data as an XML file to FTP.

## **XML Parsing and Mapping**

#### **When Reading from FTP**

* Upload or define the **XML schema** again.
* This structure tells the system how to **parse** the incoming XML.

<figure><img src="https://1036205596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv9avy716UiAsS24zOznZ%2Fuploads%2FbhCt8kNmN0H0SF2HdH3Q%2Fimage%20(26).png?alt=media&#x26;token=504dd480-c8d9-4ddd-b4f2-6effedcbe6b6" alt=""><figcaption></figcaption></figure>

#### **Mapping to CRM**

* After parsing:
  * Go to the **Console/Mapping screen**
  * Fields defined in the schema will appear
  * **Drag and drop** fields from the XML to the CRM fields

### **Key Concepts**

| Term              | Description                                              |
| ----------------- | -------------------------------------------------------- |
| **XML Structure** | Blueprint of how data is formatted in XML                |
| **Schema**        | Field definitions used for mapping and parsing           |
| **Compose**       | Interface where users define filename structure          |
| **Test Output**   | Sample result to validate XML correctness                |
| **Mapping**       | Field-to-field connection between source and destination |

#### **Best Practices**

* Always use a **sample file** to derive the XML schema.
* Validate the structure using the **Test** function before finalizing.
* Use **ChatGPT or similar tools** for fast conversion of sample data (like JSON or tables) into XML to use in the Read or Parse operationsz.
* For complex mappings, take **screenshots** and document field relationships.
* Ensure that XML field names match **Salesforce API field names** or source system labels.

### **Operation Examples**

#### **Common Scenarios to use the XML Action**

* Salesforce to FTP: Read Salesforce Opportunity data, compose XML with dynamic fields (like DateTime), configure schema, test, and write to an FTP path as XML.
* FTP to CRM: Read XML from FTP, parse using the defined schema, and write to a CRM by mapping XML fields to CRM fields.

#### **Scenario 1: Salesforce to FTP**

* **Read** from Salesforce Opportunity
* **Compose** the data structure (including dynamic fields like DateTime)
* **Configure XML**
  * Define the XML structure using sample file format
  * Generate XML based on Salesforce fields
  * Test the XML schema
* **Write** the structured XML to an FTP path

#### **Scenario 2: FTP to CRM**

* **Read** XML from FTP
* **Parse** using defined schema
* **Write** to CRM system (e.g., Console)
  * Drag and drop mapping fields based on the schema

<details>

<summary>Frequently Asked Questions</summary>

1\. Can I automate XML integrations on a schedule?\
Yes, DBSync supports flexible scheduling for XML integration jobs—hourly, daily, or custom intervals.\
\
2\. What if my XML structure changes?\
Update your sample file and schema in the XML Storage Action, then revalidate using the Test function.\
\
3\. Which systems are supported?\
You can integrate with popular CRMs (Salesforce, HubSpot, Microsoft Dynamics 365), ERPs (QuickBooks, NetSuite), cloud storage (AWS S3, Google Drive, FTP/SFTP), and more.

</details>
