$xmlContent = file_get_contents(__DIR__ . '/myFile.xml'); $contentToObject = new SimpleXMLElement($xmlContent); $jsonData = json_encode($contentToObject, JSON_UNESCAPED_SLASHES);