function json2xml($json) {

  1. require_once 'XML/Serializer.php';
  2. $serializer_options = [
  3. 'addDecl' => true,
  4. 'addDoctype' => true,
  5. 'doctype' => [
  6. 'id' => 'pubmed api',
  7. 'uri' => 'http://39.106.135.106/pubmed/api/',
  8. ],
  9. 'encoding' => 'UTF-8',
  10. 'indent' => ' ',
  11. 'rootName' => 'result',
  12. 'mode' => 'simplexml',
  13. ];
  14. $Serializer = &new XML_Serializer($serializer_options);
  15. $status = $Serializer->serialize($json);
  16. if (PEAR::isError($status)) {
  17. die($status->getMessage());
  18. }
  19. header('Content-type: text/xml');
  20. echo $Serializer->getSerializedData();

}

// $data = … json2xml($data); ```