src/Pakettikauppa/Shipment.php
private function toXml()
    {
        $xml = new SimpleXMLElement('<eChannel/>');

        $routing = $xml->addChild('ROUTING');
        $routing->addChild("Routing.Time", time());

        $shipment = $xml->addChild('Shipment');

        $sender = $shipment->addChild('Shipment.Sender');
        $sender->addChild('Sender.Name1', $this->sender->getName1());
        $sender->addChild('Sender.Name2', $this->sender->getName2());
        $sender->addChild('Sender.Addr1', $this->sender->getAddr1());
        $sender->addChild('Sender.Addr2', $this->sender->getAddr2());
        $sender->addChild('Sender.Addr3', $this->sender->getAddr3());
        $sender->addChild('Sender.Postcode', $this->sender->getPostcode());
        $sender->addChild('Sender.City', $this->sender->getCity());
        $sender->addChild('Sender.Country', $this->sender->getCountry());
        $sender->addChild('Sender.Phone', $this->sender->getPhone());
        $sender->addChild('Sender.Vatcode', $this->sender->getVatcode());

        $receiver = $shipment->addChild('Shipment.Recipient');
        $receiver->addChild('Recipient.Name1', $this->receiver->getName1());
        $receiver->addChild('Recipient.Name2', $this->receiver->getName2());
        $receiver->addChild('Recipient.Addr1', $this->receiver->getAddr1());
        $receiver->addChild('Recipient.Addr2', $this->receiver->getAddr2());
        $receiver->addChild('Recipient.Addr3', $this->receiver->getAddr3());
        $receiver->addChild('Recipient.Postcode', $this->receiver->getPostcode());
        $receiver->addChild('Recipient.City', $this->receiver->getCity());
        $receiver->addChild('Recipient.Country', $this->receiver->getCountry());
        $receiver->addChild('Recipient.Phone', $this->receiver->getPhone());
        $receiver->addChild('Recipient.Vatcode', $this->receiver->getVatcode());
        $receiver->addChild('Recipient.Email', $this->receiver->getEmail());

        $consignment = $shipment->addChild('Shipment.Consignment');
        $consignment->addChild('Consignment.Reference', $this->shipment_info->getReference());
        $consignment->addChild('Consignment.Product', $this->shipping_method);
        $consignment->addChild('Consignment.Contentcode', $this->shipment_info->getContentCode());
        $consignment->addChild('Consignment.ReturnInstruction', $this->shipment_info->getReturnInstruction());
        $consignment->addChild('Consignment.Invoicenumber', $this->shipment_info->getInvoiceNumber());
        $consignment->addChild('Consignment.Merchandisevalue', $this->shipment_info->getMerchandiseValue());

        foreach ($this->additional_services as $service)
        {
            if($service->isValid())
            {
                $additional_service = $consignment->addChild('Consignment.AdditionalService');
                $additional_service->addChild('AdditionalService.ServiceCode', $service->getServiceCode());

                foreach ($service->getSpecifiers() as $nameValue)
                {
                    $specifier          = $additional_service->addChild('AdditionalService.Specifier', $nameValue[1]);
                    $specifier['name']  = $nameValue[0];
                }
            }
        }

        $additional_info = $consignment->addChild('Consignment.AdditionalInfo');
        $additional_info->addChild('AdditionalInfo.Text', $this->shipment_info->getAdditionalInfoText());

        foreach ($this->parcels as $parcel)
        {
            $parcel_xml = $consignment->addChild('Consignment.Parcel');
            $parcel_xml->addChild('Parcel.Reference', $parcel->getReference());
            $parcel_xml->addChild('Parcel.PackageType', $parcel->getPackageType());
            $weight = $parcel_xml->addChild('Parcel.Weight', $parcel->getWeight());
            $volume = $parcel_xml->addChild('Parcel.Volume', $parcel->getVolume());

            $weight['unit'] = 'kg';
            $volume['unit'] = 'm3';

            $parcel_xml->addChild('Parcel.Infocode', $parcel->getInfocode());
            $parcel_xml->addChild('Parcel.Contents', $parcel->getContents());

            if($this->print_return_label)
                $parcel_xml->addChild('Parcel.ReturnService', 2108);

            foreach ($parcel->getContentLines() as $content_line)
            {
                $content = $parcel_xml->addChild('Parcel.contentline');
                $content->addChild('contentline.description', $content_line->getDescription());
                $content->addChild('contentline.quantity', $content_line->getQuantity());
                $content->addChild('contentline.currency', $content_line->getCurrency());
                $content->addChild('contentline.netweight', $content_line->getNetweight());
                $content->addChild('contentline.value', $content_line->getValue());
                $content->addChild('contentline.countryoforigin', $content_line->getCountryOfOrigin());
                $content->addChild('contentline.tariffcode', $content_line->getTariffCode());
            }
        }

        return $xml;
    }
private function toXml()
    {
        $xml = new SimpleXMLElement('<eChannel/>');

        $routing = $xml->addChild('ROUTING');
        $routing->addChild("Routing.Time", time());

        $shipment = $xml->addChild('Shipment');

        $sender = $shipment->addChild('Shipment.Sender');
        $sender->addChild('Sender.Name1', $this->sender->getName1());
        $sender->addChild('Sender.Name2', $this->sender->getName2());
        $sender->addChild('Sender.Addr1', $this->sender->getAddr1());
        $sender->addChild('Sender.Addr2', $this->sender->getAddr2());
        $sender->addChild('Sender.Addr3', $this->sender->getAddr3());
        $sender->addChild('Sender.Postcode', $this->sender->getPostcode());
        $sender->addChild('Sender.City', $this->sender->getCity());
        $sender->addChild('Sender.Country', $this->sender->getCountry());
        $sender->addChild('Sender.Phone', $this->sender->getPhone());
        $sender->addChild('Sender.Vatcode', $this->sender->getVatcode());

        $receiver = $shipment->addChild('Shipment.Recipient');
        $receiver->addChild('Recipient.Name1', $this->receiver->getName1());
        $receiver->addChild('Recipient.Name2', $this->receiver->getName2());
        $receiver->addChild('Recipient.Addr1', $this->receiver->getAddr1());
        $receiver->addChild('Recipient.Addr2', $this->receiver->getAddr2());
        $receiver->addChild('Recipient.Addr3', $this->receiver->getAddr3());
        $receiver->addChild('Recipient.Postcode', $this->receiver->getPostcode());
        $receiver->addChild('Recipient.City', $this->receiver->getCity());
        $receiver->addChild('Recipient.Country', $this->receiver->getCountry());
        $receiver->addChild('Recipient.Phone', $this->receiver->getPhone());
        $receiver->addChild('Recipient.Vatcode', $this->receiver->getVatcode());
        $receiver->addChild('Recipient.Email', $this->receiver->getEmail());

        $consignment = $shipment->addChild('Shipment.Consignment');
        $consignment->addChild('Consignment.Reference', $this->shipment_info->getReference());
        $consignment->addChild('Consignment.Product', $this->shipping_method);
        $consignment->addChild('Consignment.Contentcode', $this->shipment_info->getContentCode());
        $consignment->addChild('Consignment.ReturnInstruction', $this->shipment_info->getReturnInstruction());
        $consignment->addChild('Consignment.Invoicenumber', $this->shipment_info->getInvoiceNumber());
        $consignment->addChild('Consignment.Merchandisevalue', $this->shipment_info->getMerchandiseValue());

        foreach ($this->additional_services as $service)
        {
            if($service->isValid())
            {
                $additional_service = $consignment->addChild('Consignment.AdditionalService');
                $additional_service->addChild('AdditionalService.ServiceCode', $service->getServiceCode());

                foreach ($service->getSpecifiers() as $nameValue)
                {
                    $specifier          = $additional_service->addChild('AdditionalService.Specifier', $nameValue[1]);
                    $specifier['name']  = $nameValue[0];
                }
            }
        }

        $additional_info = $consignment->addChild('Consignment.AdditionalInfo');
        $additional_info->addChild('AdditionalInfo.Text', $this->shipment_info->getAdditionalInfoText());

        foreach ($this->parcels as $parcel)
        {
            $parcel_xml = $consignment->addChild('Consignment.Parcel');
            $parcel_xml->addChild('Parcel.Reference', $parcel->getReference());
            $parcel_xml->addChild('Parcel.PackageType', $parcel->getPackageType());
            $weight = $parcel_xml->addChild('Parcel.Weight', $parcel->getWeight());
            $volume = $parcel_xml->addChild('Parcel.Volume', $parcel->getVolume());

            $weight['unit'] = 'kg';
            $volume['unit'] = 'm3';

            $parcel_xml->addChild('Parcel.Infocode', $parcel->getInfocode());
            $parcel_xml->addChild('Parcel.Contents', $parcel->getContents());

            if($this->print_return_label)
                $parcel_xml->addChild('Parcel.ReturnService', 2108);

            foreach ($parcel->getContentLines() as $content_line)
            {
                $content = $parcel_xml->addChild('Parcel.contentline');
                $content->addChild('contentline.description', $content_line->getDescription());
                $content->addChild('contentline.quantity', $content_line->getQuantity());
                $content->addChild('contentline.currency', $content_line->getCurrency());
                $content->addChild('contentline.netweight', $content_line->getNetweight());
                $content->addChild('contentline.value', $content_line->getValue());
                $content->addChild('contentline.countryoforigin', $content_line->getCountryOfOrigin());
                $content->addChild('contentline.tariffcode', $content_line->getTariffCode());
            }
        }

        return $xml;
    }
Builds the xml from given data

@return SimpleXMLElement