Skip to content

Instantly share code, notes, and snippets.

@jklein
Created April 20, 2013 17:32
Show Gist options
  • Save jklein/5426753 to your computer and use it in GitHub Desktop.
Save jklein/5426753 to your computer and use it in GitHub Desktop.
Export Joomla 1.5 users to XML
<?php
$m = new mysqli('localhost', 'root', '<password>', 'buda_prod');
$result = $m->query('Select * from jos2_users');
while ($row = $result->fetch_assoc()) {
$results[] = $row;
}
$xml = '<?xml version="1.0" encoding="UTF-8" ?>' . PHP_EOL;
$xml .= '<!DOCTYPE j2xml PUBLIC "-//eshiol.it//DTD J2XML data file 1.5.6//EN" "http://www.eshiol.it/j2xml/1506/j2xml.dtd">' . PHP_EOL;
$xml .= '<j2xml version="1.5.6">' . PHP_EOL;
foreach ($results as $row) {
$xml .= '<user mapkeystotext="true">' . "\n";
foreach ($row as $key => $value) {
$xml .= "<$key><![CDATA[$value]]></$key>\n";
}
$xml .= '</user>' . "\n";
}
$xml .= '</j2xml>';
file_put_contents('users.xml', $xml);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment