Search code examples
phpsymfonyjmsserializerbundlesymfony-3.4jms-serializer

Deserialize XML with JMS Symfony 3.4


I have some trouble with JMS Serializer - I need to deserialize a XML but i have an exception.

For example, for the xml

<test><name>Test</name></test>

I'm doing :

$xml = $paramFetcher->get('xml');
$serializer = SerializerBuilder::create()->build();
$serializer->deserialize($stack, MyObject::class, 'xml');

And with that, JMS return :

<exception class="JMS\Parser\SyntaxErrorException" message="Expected end of input, but got &quot;&gt;&quot; of type T_CLOSE_BRACKET at position 37 (0-based).">

at JMS\Serializer\Serializer->deserialize('&lt;test&gt;&lt;name&gt;Test&lt;/name&gt;&lt;/test&gt;', 'MyObject::class', 'xml')

The XML is sent in POST 'form-data' with other RequestParam.

jms/serializer-bundle 2.4.2


Solution

  • The problem was solved by changing a namespace in one of my entities. I checked all namespace, and one of this namespace was not correct.