PHP code example of kudrmichal / serializer
1. Go to this page and download the library: Download kudrmichal/serializer 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/ */
kudrmichal / serializer example snippets
$xml = <<<XML
<test testAttributeInt="123">
<testInteger>321</testInteger>
<testString>321</testString>
<testBoolean>1</testBoolean>
<testDate>2022-02-22</testDate>
<testArrayItem>1</testArrayItem>
<testArrayItem>2</testArrayItem>
<testArrayItem>3</testArrayItem>
<testNestedArray>
<testNestedArrayItem>3</testNestedArrayItem>
<testNestedArrayItem>2</testNestedArrayItem>
<testNestedArrayItem>1</testNestedArrayItem>
</testNestedArray>
<testObject testAttributeInt="10">
<testInteger>9</testInteger>
<testObjectString>test</testObjectString>
</testObject>
<testObjectNestedArray>
<testObject>
<testInteger>5</testInteger>
</testObject>
<testObject>
<testInteger>6</testInteger>
<testObjectString>true</testObjectString>
</testObject>
</testObjectNestedArray>
</test>
XML;
$doc = new \DOMDocument();
$doc->loadXML($xml);
$deserializer = new \KudrMichal\Serializer\Xml\Deserializer();
$test = $deserializer->deserialize($doc, \KudrMichal\Serializer\Tests\Unit\Xml\Classes\Test::class);