How do I install json in xampp server?
Json is a format; you don't install it, you implement it.
If you want to use the json format in your php website, there's an extension that provides functions you can use to encode data in a json format.
To install or use the extension, please see the installation page; depending on your version of php you may have the json extension already bundled with xampp. If you've got the latest version of xampp (windows install), it's ok to use the methods directly
Xampp is "shipped" with Apache, MySQL, PHP, Perl and support for JSON in PHP and Perl!
Json Perl: JSON::to_json(hash);
Simple PHP example from php.net
<?php
$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr);
?>
EDIT: Second example showing how to json_encode() a mysql query result:
<?php
$sth = mysql_query("SELECT ...");
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
?>
EDIT 2: You are then able to convert JSON to XML using one of the described methods from this stackoverflow question.
Edit3: If you want to save the xml file to disc use
$myFile = "file.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
$data = x; // replace x with the xml from your ajax result !!!!!
fwrite($fh, $data);
fclose($fh);