PHP code example of mtownsend / collection-xml

1. Go to this page and download the library: Download mtownsend/collection-xml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mtownsend / collection-xml example snippets


/*
 * Package Service Providers...
 */
Mtownsend\CollectionXml\Providers\CollectionXmlServiceProvider::class,

$app->register(Mtownsend\CollectionXml\Providers\CollectionXmlServiceProvider::class);

$collection = collect([
    'carrier' => 'fedex',
    'id' => 123,
    'tracking_number' => '9205590164917312751089',
]);

$xml = $collection->toXml();

// Returns
<?xml version="1.0"

$collection = collect([
    'carrier' => 'fedex',
    'id' => 123,
    'tracking_number' => '9205590164917312751089',
]);

$xml = $collection->toSoapXml('request', 'xmlBody', 'https://yourwebserver/service.asmx?wsdl');

// Returns
<?xml version="1.0" encoding="UTF-8"

$array = [
    'carrier' => 'fedex',
    'id' => 123,
    'tracking_number' => '9205590164917312751089',
];

$xml = array_to_xml($array);