Mar 1, 2010

I’m working in a hsphere to cpanel migration project and my question is about how can I parse a xml file into cpanel, I want to create a xml file with all account information (username, domains, password, databases, etc) and then parse this file in cpanel for the account creation, is this possible ? how? or the only way is from whm and api's?

Thanks in Advance


Well-Known Member
Staff member
Dec 17, 2009
Houston, TX
cPanel Access Level
Root Administrator
Migration to cPanel

Hi samuelaciego,

One way to start your project would be to use the XMLAPI, (XML and JSON APIs). You could creating a script that parses your XML data into an API query; could use the createacct method and establish your accounts.

If you're familiar with PHP, we have a convenience class XMLAPI.php found here
Index of /lib/xmlapi/php

Just grab the latest version and untar it. In there you'll find the class and some example scripts :)

Importing databases/schema maybe a little more difficult. However, once you have the accounts created, I'm sure there's a few ways to get there. Caveat Emptor: cPanel, like many host management environments utilizes a 'username_' database naming convention. This should actually help you for the import, but future product versions may use a different user/db ownership paradigm...FYI

I would consider utilizing the XMLAPI and performing a api1_query for db creation. Here is where the mysql api calls are documented: ApiMysql < ApiDocs < TWiki

Once the db is created, it should be easy enough to perform a scripted mysql-import for the data itself. In this way, cPanel would handle db creation all the proper grants and you're only responsible for the data :). Again, it may take a little trial and error, but having the API do the heavy lifting is certainly the preferred method.

Hope this gets you pointed in the right direction.


PS. you can use whatever method you wish to perform the API call, the PHP class is just one way ;)


Jan 20, 2011
We're looking for help (can pay) for moving 550+ domains from Hsphere to Enkompass. Anyone do that?