Export xml to file and save in a specific folder

Scriptcase offers an option to export to XML in the grid. When XML is created, you have the option to view and save to or open.

I am looking for a solution to save this XML to the disk hosting server where the application runs into a specific folder. I read all the topics, but unfortunately I can not find any solution.

I suppose I should create a button that would create XML and save it to disk. But I do not know how.

Does anyone have any solution to this code and how to implement it?

Thanks.

I have the same question. Also how to handle the style infromation. Names of tags etc

You can do it programmatically if you desire. Maybe easier than trying todo it through a grid

//SQL query
$sql = “SELECT emre.EMP_ID, emre.FIRST_NAME, emre.STATUS, emre.START_DATE FROM employee_reg emre”;

// Macro to execute the query
sc_select(ds, $sql);

// Check if the dataset contains any records
if (false !== {ds}) {
$xmlContent = “<?xml version='1.0' encoding='UTF-8'?>\n\n”;

// Iterate through the dataset till End Of File
while (!{ds}->EOF) {
    $xmlContent .= "\t<employee>\n";
    $xmlContent .= "\t\t<EMP_ID>" . htmlspecialchars({ds}->fields[0]) . "</EMP_ID>\n";
    $xmlContent .= "\t\t<FIRST_NAME>" . htmlspecialchars({ds}->fields[1]) . "</FIRST_NAME>\n";
    $xmlContent .= "\t\t<STATUS>" . htmlspecialchars({ds}->fields[2]) . "</STATUS>\n";
    $xmlContent .= "\t\t<START_DATE>" . htmlspecialchars({ds}->fields[3]) . "</START_DATE>\n";
    $xmlContent .= "\t</employee>\n";
    
    {ds}->MoveNext();
}
{ds}->Close();
$xmlContent .= "</employees>";

// Define the path and filename for the XML file.  You will see this gets saved in the root folder
$filePath = $_SERVER['DOCUMENT_ROOT'] . "/employees.xml"; // Adjust the path as needed

// Save XML content to the file if any records exist 
if(file_put_contents($filePath, $xmlContent)) {
    echo "YOur XML file has been created successfully.";
} else {
    echo "Failed to create the XML file. Check permissions, Path and Privileges ";
}

} else {
echo “No data found.”;
}

Thanks for your answer. Indeed I have to make my own script. Regards Bert