Add <!DOCTYPE to serialized xml from symfony serializer

111 Views Asked by At

There is xmlencoder in symfony serializer, by using that we achive this.

$data = ['foo' => 'Foo value'];
$encoder = new XmlEncoder();
$encoder->encode($data, 'xml');

// is encoded as follows:
// <?xml version="1.0"?>
// <response>
//     <foo>
//        Foo value
//     </foo>
// </response>

Now we need to add <!DOCTYPE something like below

// is encoded as follows:
// <?xml version="1.0"?>
// <!DOCTYPE response SYSTEM "pathto.dtd">
// <response>
// .....

Is there a way to achieve this with symfony serializer?

0

There are 0 best solutions below