> For the complete documentation index, see [llms.txt](https://mini-eric.docs.rechtlogisch.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mini-eric.docs.rechtlogisch.de/documentation/examples/examples.md).

# Examples

## XML Examples

This section provides ready-to-use XML examples for various ELSTER data types and use cases.

{% hint style="success" %}
You find ready to use examples inside the (PHP) package shared with you.
{% endhint %}

### XML Structure

All ELSTER XML documents follow this basic structure:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<DatenTeil>
    <Nutzdatenblock>
        <NutzdatenHeader version="11">
            <NutzdatenTicket>unique_ticket_within_xml</NutzdatenTicket>
            <Empfaenger id="F|L">recipient_id</Empfaenger>
            <!-- Optional: Hersteller, DatenLieferant -->
        </NutzdatenHeader>
        <Nutzdaten>
            <!-- Data type specific content -->
        </Nutzdaten>
    </Nutzdatenblock>
</DatenTeil>
```

### Account Information (Kontoinformation)

```xml
<?xml version="1.0" encoding="UTF-8"?>
<DatenTeil>
    <Nutzdatenblock>
        <NutzdatenHeader version="11">
            <NutzdatenTicket>0</NutzdatenTicket>
            <Empfaenger id="L">CS</Empfaenger>
        </NutzdatenHeader>
        <Nutzdaten>
            <Kontoinformation version="1" />
        </Nutzdaten>
    </Nutzdatenblock>
</DatenTeil>
```

**Usage:**

{% code overflow="wrap" %}

```bash
ceric --pathXml info.xml --dataType Kontoinformation --pathStorage /storage/
```

{% endcode %}

### Data Retrieval (Postfach Operations)

#### Postfach Request (PostfachAnfrage)

```xml
<?xml version="1.0" encoding="UTF-8"?>
<DatenTeil>
    <Nutzdatenblock>
        <NutzdatenHeader version="11">
            <NutzdatenTicket>1</NutzdatenTicket>
            <Empfaenger id="L">CS</Empfaenger>
        </NutzdatenHeader>
        <Nutzdaten>
            <Datenabholung xmlns="http://finkonsens.de/elster/elsterdatenabholung/v3" version="31">
                <PostfachAnfrage>
                    <DatenartBereitstellung name="KMVProtokoll" />
                </PostfachAnfrage>
            </Datenabholung>
        </Nutzdaten>
    </Nutzdatenblock>
</DatenTeil>
```

**Usage:**

{% code overflow="wrap" %}

```bash
ceric --pathXml inbox-31-list.xml --dataType PostfachAnfrage_31 --pathStorage /storage/
```

{% endcode %}

#### Postfach Confirmation (PostfachBestaetigung)

```xml
<?xml version="1.0" encoding="UTF-8"?>
<DatenTeil>
    <Nutzdatenblock>
        <NutzdatenHeader version="11">
            <NutzdatenTicket>1</NutzdatenTicket>
            <Empfaenger id="L">CS</Empfaenger>
        </NutzdatenHeader>
        <Nutzdaten>
            <Datenabholung xmlns="http://finkonsens.de/elster/elsterdatenabholung/v3" version="31">
                <PostfachBestaetigung>
                    <Bereitstellungen>
                        <Bereitstellung id="be2594qmfqh9t25znipwrdhaie48kwxw" />
                    </Bereitstellungen>
                </PostfachBestaetigung>
            </Datenabholung>
        </Nutzdaten>
    </Nutzdatenblock>
</DatenTeil>
```

**Usage:**

{% code overflow="wrap" %}

```bash
ceric --pathXml inbox-31-confirm.xml --dataType PostfachBestaetigung_31 --pathStorage /storage/
```

{% endcode %}

### Protocol Examples

#### Download Protocol Response

```xml
<Protokoll version="6"
    xmlns="http://www.elsterfachmethodik.de/protokollverfahren/version6/XMLSchema">
    <ZeitStempel>20250916171901</ZeitStempel>
    <DatenTeil transferTicket="eh259046x46502418gprx8a9ywtdtc42" code="0" text="Datenlieferung ok.">
        <Nutzdatenblock nutzdatenTicket="1" code="2" text="Daten geprüft und korrekt."
            verarbeiteteNdS="1" nichtverarbeiteteNdS="0"></Nutzdatenblock>
    </DatenTeil>
</Protokoll>
```

**Usage:**

{% code overflow="wrap" %}

```bash
cotto --objectUuid 41a42915-d8ba-45c7-89e6-6b875a853fc4 --pathStorage /storage/
```

{% endcode %}

## PHP SDK Examples

#### Processing with PHP SDK

```php
<?php
use Rechtlogisch\MiniEric\Ceric;
use Rechtlogisch\MiniEric\Dto\CericInput;

$ceric = new Ceric();

// Process account information
$result = $ceric->draft(new CericInput(
    dataType: 'Kontoinformation',
    pathXml: 'info.xml',
    pathStorage: '/storage/',
    timestamp: '202501011200450100'
));

// Process FSE
$result = $ceric->send(new CericInput(
    dataType: 'ElsterFSE_EUn_202401',
    pathXml: 'fse.xml',
    pathStorage: '/storage/',
    timestamp: '202601011200450100'
));

// Process commercial registration
$result = $ceric->transmit(new CericInput(
    dataType: 'Gewerbemeldung',
    pathXml: 'gan.xml',
    pathStorage: '/storage/'
));

// Download data
$result = $ceric->download(new CottoInput(
    objectUuid: '41a42915-d8ba-45c7-89e6-6b875a853fc4',
    pathStorage: '/storage/'
));
```

### Troubleshooting

#### Common XML Issues

1. **Invalid XML structure**: Ensure proper XML formatting and encoding
2. **Missing required fields**: Check that all mandatory elements are present
3. **Invalid data types**: Verify data type matches the XML content
4. **Encoding issues**: Use UTF-8 encoding for all XML files

#### Validation

Use ceric in draft mode to validate XML before transmission:

{% code overflow="wrap" %}

```bash
ceric --pathXml your-file.xml --dataType YourDataType --usecase draft --pathStorage /storage/
```

{% endcode %}

### Related Topics

* [CLI Reference](/documentation/cli/cli-reference.md) - Complete command-line reference
* [PHP SDK API](/documentation/php-sdk/overview.md) - PHP SDK documentation
* [Troubleshooting](https://github.com/rechtlogisch/docs-mini-eric/blob/main/help/troubleshooting.md) - Common issues and solutions
