Answer the question
In order to leave comments, you need to log in
How to output XML with JMSSerializer without header?
Actually, the body itself is needed, without
<?xml version="1.0" encoding="UTF-8"?>
I do initialization like this.
$namingStrategy = new \JMS\Serializer\Naming\IdenticalPropertyNamingStrategy();
$annotationStrategy = new \JMS\Serializer\Naming\SerializedNameAnnotationStrategy($namingStrategy);
$serializer = \JMS\Serializer\SerializerBuilder::create()
->setPropertyNamingStrategy($annotationStrategy)
->build();
AnnotationRegistry::registerAutoloadNamespace('JMS\Serializer\Annotation', __DIR__ . '/../vendor/jms/serializer/src');
$serializedContent = \JMS\Serializer\SerializationContext::create();
$xml = $serializer->serialize($object, 'xml', $serializedContent);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question