+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 10 of 15

Thread: XML Result from PHP?

  1. #1
    Learning Programmer Ricardo-san will become famous soon enough
    Join Date
    Jan 2009
    Posts
    54

    XML Result from PHP?

    Ok...so I have a PHP file that is communicating with the API of one of my Perl programs. Basically, it creates an account then outputs an XML file in a $result variable.
    Never used XML before, so I'm wondering how I would format this? I think I can use XSLT, but I need to dynamically format this?
    Sorry if it's confusing.

  2. #2
    Moderator Orjan is a glorious beacon of light Orjan is a glorious beacon of light Orjan is a glorious beacon of light Orjan is a glorious beacon of light Orjan is a glorious beacon of light Orjan's Avatar
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Age
    34
    Posts
    2,613
    Blog Entries
    7

    Re: XML Result from PHP?

    everything is depending on how you want it. I have made quick and dirty solutions by looping with mysql, but there are built in functions in php also.

    first thing I'd do, is to go to W3Schools Online Web Tutorials and learn about how xml is done.
    __________________________________________
    Ask me: Orjan | Contribute to the Wiki! | Make your own Programming blog!
    I usually play eRepublik and Travian when I'm not on CodeCall

  3. #3
    Co-Administrator John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John's Avatar
    Join Date
    Jul 2006
    Age
    21
    Posts
    5,885
    Blog Entries
    25

    Re: XML Result from PHP?

    I am a little unclear as to what you are asking. Are you asking how you would output the XML or how you would parse the XML?

  4. #4
    Learning Programmer Ricardo-san will become famous soon enough
    Join Date
    Jan 2009
    Posts
    54

    Re: XML Result from PHP?

    Ok. I'm trying to get the createacct function to work using cPanel WHM API.
    Here's createacct.php
    Code:
    <?php
    header
    ('Content-Type: text/xml');
    echo 
    "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
    echo 
    "<?xml-stylesheet type=\"text/xsl\" href=\"style.xsl\"?>";

    # cpanel12 - createacct_example.php                Copyright(c) 1997-2009 cPanel, Inc.
    #                                                           All Rights Reserved.
    # copyright@cpanel.net                                         http://cpanel.net

    include("xmlapi.php.inc");

    $ip "127.0.0.1";
    $kh3us_pass "*********";

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("kh3us",$kh3us_pass);

    $xmlapi->set_debug(1);

    $acct = array( username => "souser"password => "pass123"domain => "thdomain.com");
    print 
    $xmlapi->createacct($acct);
    ?>
    xmlapi.php.inc
    Code:
    <?php

    # cpanel12 - xmlapi.php.inc                Copyright(c) 1997-2009 cPanel, Inc.
    #                                                           All Rights Reserved.
    # copyright@cpanel.net                                         http://cpanel.net
    # Version 1.0

    class xmlapi {
        public 
    $host;
        public 
    $curl;
        
        private 
    $port 2087;
        private 
    $protocol "https://";
        private 
    $debug 0;
        private 
    $return_xml 0;

        function 
    __construct($host) {
            
    $this->host $host;
            
    $this->curl curl_init();                                # Create Curl Object
            
    curl_setopt($this->curlCURLOPT_SSL_VERIFYPEER,0);
             
    curl_setopt($this->curlCURLOPT_RETURNTRANSFER,1);        # Return contents of transfer on curl_exec
            
    curl_setopt($this->curlCURLOPT_SSL_VERIFYHOST,0);        # Allow self-signed certs
        
    }
        
        function 
    __destruct() {
            
    curl_close($this->curl);                                # destroy curl object on unset
        
    }
        
        public function 
    set_debug($debug) {
            
    $this->debug $debug;
        }

        public function 
    set_port($port) {
            
    $this->port $port;
            if (
    $port == "2087" || $port == "2083" || $port == "443") {
                
    $this->protocol "https://";
            } else {
                
    $this->protocol "http://";
            }
        }
        
        public function 
    return_xml($value ) {
            
    $this->return_xml 1;
        }
        
        public function 
    return_object($value 1) {
            
    $this->return_xml 0;
        }
        
        public function 
    password_auth($username,$password) {
            
    curl_setopt($this->curlCURLOPT_USERPWD$username.":".$password);
        }
        
        public function 
    hash_auth($user,$hash) {
            
    $header[0] = "Authorization: WHM $user:" preg_replace("'(\r|\n)'","",$hash);
            
    curl_setopt($this->curl,CURLOPT_HTTPHEADER,$header);
        }

        public function 
    xmlapi_query($function$calls = array()) {
            if (!
    $function) {
                
    error_log("xmlapi_query() requires a function to be passed to it");
                return;
            }
            
            
    $args http_build_query($calls);
            
    $query =  $this->protocol $this->host ":" $this->port "/xml-api/" $function "?" $args;

            if (
    $this->debug) {
                print 
    "\n\nQUERY:\n" $query "\n\n";
            }

            
    curl_setopt($this->curlCURLOPT_URL$query);
            
    $result curl_exec($this->curl);

            if (
    $result == false) {
                
    error_log("curl_exec threw error \"" curl_error($this->curl) . "\" for $query");
            }

            if (
    $this->return_xml) {
                if (
    $this->debug) {
                    print 
    "RAW XML:\n\n$result\n\n";
                }
                return 
    $result;
            } else {
                if (
    $this->debug) {
                    print 
    "RAW XML:\n\n$result\n\n";
                    print 
    "SIMPLEXML OBJ:\n\n" var_dump(simplexml_load_string($result)) . "\n\n";
                }
                return 
    simplexml_load_string($result);
            }

        }
        
        
        
        public function 
    api1_query($user,$module,$function,$args) {
            
    $api_call = array(
                
    module => $module,
                
    func => $function,
                
    apiversion => "1",
                
    args => $args
            
    );
            
            
    $call = array(
                
    user => $user,
                
    xmlin => $this->build_api1_call($api_call),
            );
            
            return 
    $this->xmlapi_query("cpanel",$call);
        }
        
        public function 
    api2_query($user,$module,$function,$args) {
            
    $api_call = array(
                
    module => $module,
                
    func => $function,
                
    args => $args
            
    );
            
            
    $call = array(
                
    user => $user,
                
    xmlin => $this->build_api2_call($api_call)
            );
            return 
    $this->xmlapi_query("cpanel",$call);
        }
        
        public function 
    build_api2_call($input) {
            
    $output "<cpanelaction>";
            foreach(
    $input as $tag => $data) {
                if (
    is_array($data)) {
                    
    $output .= "<args>";
                    foreach (
    $data as $arg_tag => $arg) {
                        
    $output .= "<$arg_tag>" $arg "</$arg_tag>";
                    }
                    
    $output .= "</args>";
                } else {
                   
    $output .= "<$tag>" $data "</$tag>";
                }
            }
            
    $output .= "</cpanelaction>";
            if (
    $this->debug) {
                print 
    "\n\nRAW API2 CALL:\n" $output "\n\n";
            }
            return 
    $output;
        }

        public function 
    build_api1_call($input) {
            
    $output "<cpanelaction>";
            foreach(
    $input as $tag => $data) {
                if (
    is_array($data)) {
                    foreach (
    $data as $arg) {
                        
    $output .= "<args>" $arg "</args>";
                    }
                } else {
                   
    $output .= "<$tag>" $data "</$tag>";
                }
            }
            
    $output .= "</cpanelaction>";
            if (
    $this->debug) {
                print 
    "\n\nRAW API1 CALL:\n" $output "\n\n";
            }
            return 
    $output;
        }
        
        
    ####
        #  XML API Functions
        ####
        
        ####
        # Accounting
        ####
        
        
        ####
        # createacct($accthash)
        # This needs to be passed in a hash where username, password and domain are all defined.
        # all other arguments are optional
        ####
        
    public function createacct($acctinfo) {
            if (!isset(
    $acctinfo['username']) || !isset($acctinfo['password']) || !isset($acctinfo['domain'])) {
                
    error_log("createacct requires that username, password & domain elements are in the array passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("createacct"$acctinfo);
        }
        
        
        public function 
    removeacct($username) {
            if (!isset(
    $username)) {
                
    error_log("killacct requires that a username is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("removeacct",array("user" => $username));
        }
        
        public function 
    passwd($user,$pass){
            if (!isset(
    $user) || !isset($pass)) {
                
    error_log("passwd requires that (username,password) are passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("passwd", array("user" => $user"pass" => $pass));
        }
        
        public function 
    listaccts($searchtype null$search null) {
            if (
    $search) {
                return 
    $this->xmlapi_query("listaccts", array( "searchtype" => $searchtype"search" => $search ) );
            } else {
                return 
    $this->xmlapi_query("listaccts");
            }
        }
        
        public function 
    accoutsummary($username) {
            if (!isset(
    $username)) {
                
    error_log("accountsummary requires that a username is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("accountsummary",array(user => $username));
        }
        
        public function 
    suspendacct($username$reason null) {
            if (!isset(
    $username)) {
                
    error_log("suspendacct requires that a username is passed to it");
                return 
    0;
            }
            if (
    $reason) {
                return 
    $this->xmlapi_query("suspendacct",array( "user" => $username"reason" => $reason ));
            } else {
                return 
    $this->xmlapi_query("suspendacct", array("user" => $username));
            }
        }
        
        public function 
    unsuspendacct($username){
            if (!isset(
    $username)) {
                
    error_log("unsuspendacct requires that a username is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("unsuspendacct", array("user" => $username));
        }
        
        public function 
    modifyacct($opts) {
            if (!isset(
    $opts['user'])) {
                
    error_log("modifyacct requires that user is defined in the array passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("modifyacct",$opts);
        }
        
        
    ####
        # Package Functions
        ####
        
        
    public function addpkg($pkg) {
            if (!isset(
    $pkg['name'])) {
                
    error_log("addpkg requires that name is defined in the array passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query('addpkg'$pkg);
        }

        public function 
    killpkg($pkg) {
            if(!isset(
    $pkg)) {
                
    error_log("killpkg requires that the package name is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query('killpkg',array("pkg" => $pkg));
        }
        
        public function 
    editpkg($pkg) {
            if (!
    $isset($pkg['name'])) {
                
    error_log("editpkg requires that name is defined in the array passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("editpkg",$pkg);
        }
        
        public function 
    listpkgs() {
            return 
    $self->query('listpkgs');
        }
        
        
    ####
        # Reseller Functions
        ####
        
        
    public function setupreseller($user,$makeowner) {
            if (!isset(
    $user) || !isset($makeowner)) {
                
    error_log("setupreseller requires that (user,makeowner) are passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("setupreseller",array("user" => $user"makeowner" => $makeowner));
        }
        
        public function 
    unsetupreseller($user) {
            if (!isset(
    $user)) {
                
    error_log("unsetupreseller requires that a reseller name is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("unsetupreseller",array("user"=>$user));
        }
        
        public function 
    listresellers() {
            return 
    $this->xmlapi_query('listresellers');
        }
        
        public function 
    saveacllist($acl) {
            if (!isset(
    $acl['acllist'])) {
                
    error_log("saveacllist requires that acllist is defined in the array passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query('saveacllist',$act);
        }
        
        public function 
    setacls($acl) {
            if (!isset(
    $acl['reseller'])) {
                
    error_log("setacls requires that reseller is defined in the array passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("setacls"$acl);
        }
        
        public function 
    terminatereseller($reseller,$terminatereseller) {
            if (!isset(
    $reseller) || !isset($terminatereseller)) {
                
    error_log("terminatereseller requires that (reseller|terminatereseller) are passed to it");
                return 
    0;
            }
            
    $verify "I%20understand%20this%20will%20irrevocably%20remove%20all%20the%20accounts%20owned%20by%20the%20reseller%20" $reseller;
            return 
    $this->xmlapi_query("terminatereseller",array("reseller" => $reseller"terminatereseller" => $terminatereseller"verify" => $verify));
        }
        
        
    ####
        # Server Info
        ####
        
        
    public function version() {
            return 
    $this->xmlapi_query("version");
        }
        
        public function 
    hostname() {
            return 
    $this->xmlapi_query('hostname');
        }
        
        
    ####
        # Service Functions
        ####
        
        
    public function restartsrv($service) {
            if (!isset(
    $service)) {
                
    error_log("restartsrv requires that service is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("restartservice",array('service' => $service));
        }
        
        public function 
    applist() {
            return 
    $this->xmlapi_query("applist");
        }
        
        public function 
    myprivs() {
            return 
    $this->xmlapi_query("myprivs");
        }
        
        public function 
    sethostname($hostname) {
            if (!isset(
    $hostname)) {
                
    error_log("sethostname requires that hostname is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("sethostname", array("hostname"=>$hostname));
        }
        
        public function 
    addip($ip,$netmask) {
            if (!isset(
    $ip,$netmask)) {
                
    error_log("addip requires that an IP address and Netmask are passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("addip",array("ip"=>$ip,"netmask"=>$netmask));
        }
        
        public function 
    delip($ip) {
            if (!isset(
    $ip)) {
                
    error_log("delip requires that an IP is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("delip", array("ip"=>$ip));
        }
        
        public function 
    listips() {
            return 
    $this->xmlapi_query("listips");
        }

        
    ####
        # DNS Functions
        ####
        
        
    public function adddns($domain,$ip) {
            if (!isset(
    $domain) || !isset($ip)) {
                
    error_log("adddns require that domain, ip are passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("adddns", array("domain"=>$domain,"ip"=>$ip));
        }
        
        public function 
    killdns($domain) {
            if (!isset(
    $domain)) {
                
    error_log("killdns requires that domain is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("killdns", array("domain"=>$domain));
        }

        public function 
    listzones() {
            return 
    $this->xmlapi_query("listzones");
        }
        
        public function 
    dumpzone($domain) {
            if (!isset(
    $domain)) {
                
    error_log("dumpzone requires that a domain is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("dumpzone",array("domain"=>$domain));
        }
        
        public function 
    lookupnsip($nameserver) {
            if (!isset(
    $nameserver)) {
                
    error_log("lookupnsip requres that a nameserver is passed to it");
                return 
    0;
            }
            return 
    $this->xmlapi_query("lookupnsip",array("nameserver"=>$nameserver));
        }

        
    }

    ?>
    After running the script, I get a blank page but this in the source code:
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="style.xsl"?>

    QUERY:
    https://127.0.0.1:2087/xml-api/createacct?username=souser&password=pass123&domain=thdomain.com

    RAW XML:

    <createacct>
      <result>
        <options>
          <ip>174.132.240.50</ip>
          <nameserver>ns1.kh3.us</nameserver>
          <nameserver2>ns2.kh3.us</nameserver2>
          <nameserver3></nameserver3>
          <nameserver4></nameserver4>
          <nameservera></nameservera>
          <nameservera2></nameservera2>
          <nameservera3></nameservera3>
          <nameservera4></nameservera4>
          <nameserverentry></nameserverentry>
          <nameserverentry2></nameserverentry2>
          <nameserverentry3></nameserverentry3>
          <nameserverentry4></nameserverentry4>
          <package>default</package>
        </options>
        <rawout>Checking input data...System has 0 free ips.
    ...DoneWWWAcct 12.1.0 (c) 1997-2008 cPanel, Inc....

    Dns Zone check is enabled.
    +===================================+
    | New Account Info                  |
    +===================================+
    | Domain: thdomain.com
    | Ip: 174.132.240.50 (n)
    | HasCgi: y
    | UserName: souser
    | PassWord: pass123
    | CpanelMod: x3
    | HomeRoot: /home
    | Quota: 0 Meg
    | NameServer1: ns1.kh3.us
    | NameServer2: ns2.kh3.us
    | NameServer3: 
    | NameServer4: 
    | Contact Email: 
    | Package: default
    | Feature List: default
    | Language: english
    +===================================+
    ...DoneRunning pre creation script (/scripts/prewwwacct)......DoneAdding User...Removing Shell Access (n)
    ...DoneCopying skel files from /home/kh3us/cpanel3-skel/ to /home/souser/......DoneAdding Entries to httpd.conf......DoneSetting up Mail &amp; Local Domains...localdomains...valiases ...vdomainaliases...vfilters......DoneConfiguring DNS......DoneRestarting apache......DoneChanging password for souser
    Password for souser has been changed
    Updating Authentication Databases...Updating ftp passwords for souser
    Ftp password files updated.
    Ftp vhost passwords synced
    ...DoneVerifying MX Records and Setting up Databases......DoneSetting up Proxy Subdomains......DoneBind reconfiguring on sapphire using rndc
    Sending Account Information......DoneSystem has 0 free ips.
    Running post creation scripts (/scripts/legacypostwwwacct, /scripts/postwwwacct, /scripts/postwwwacctuser)......Donewwwacct creation finished
    Setting up Domain Pointers......DoneSetting Reseller Privs......DoneAccount Creation Complete!!!...Account Creation Ok...Done</rawout>
        <status>1</status>
        <statusmsg>Account Creation Ok</statusmsg>
      </result>
    </createacct>

    <!-- Web Host Manager  (c) cPanel, Inc. 2008 http://cpanel.net/  Unauthorized copying is prohibited. -->


    object(SimpleXMLElement)#2 (1) {
      ["result"]=>
      object(SimpleXMLElement)#3 (4) {
        ["options"]=>
        object(SimpleXMLElement)#4 (14) {
          ["ip"]=>
          string(14) "174.132.240.50"
          ["nameserver"]=>
          string(10) "ns1.kh3.us"
          ["nameserver2"]=>
          string(10) "ns2.kh3.us"
          ["nameserver3"]=>
          object(SimpleXMLElement)#5 (0) {
          }
          ["nameserver4"]=>
          object(SimpleXMLElement)#6 (0) {
          }
          ["nameservera"]=>
          object(SimpleXMLElement)#7 (0) {
          }
          ["nameservera2"]=>
          object(SimpleXMLElement)#8 (0) {
          }
          ["nameservera3"]=>
          object(SimpleXMLElement)#9 (0) {
          }
          ["nameservera4"]=>
          object(SimpleXMLElement)#10 (0) {
          }
          ["nameserverentry"]=>
          object(SimpleXMLElement)#11 (0) {
          }
          ["nameserverentry2"]=>
          object(SimpleXMLElement)#12 (0) {
          }
          ["nameserverentry3"]=>
          object(SimpleXMLElement)#13 (0) {
          }
          ["nameserverentry4"]=>
          object(SimpleXMLElement)#14 (0) {
          }
          ["package"]=>
          string(7) "default"
        }
        ["rawout"]=>
        string(1624) "Checking input data...System has 0 free ips.
    ...DoneWWWAcct 12.1.0 (c) 1997-2008 cPanel, Inc....

    Dns Zone check is enabled.
    +===================================+
    | New Account Info                  |
    +===================================+
    | Domain: thdomain.com
    | Ip: 174.132.240.50 (n)
    | HasCgi: y
    | UserName: souser
    | PassWord: pass123
    | CpanelMod: x3
    | HomeRoot: /home
    | Quota: 0 Meg
    | NameServer1: ns1.kh3.us
    | NameServer2: ns2.kh3.us
    | NameServer3: 
    | NameServer4: 
    | Contact Email: 
    | Package: default
    | Feature List: default
    | Language: english
    +===================================+
    ...DoneRunning pre creation script (/scripts/prewwwacct)......DoneAdding User...Removing Shell Access (n)
    ...DoneCopying skel files from /home/kh3us/cpanel3-skel/ to /home/souser/......DoneAdding Entries to httpd.conf......DoneSetting up Mail & Local Domains...localdomains...valiases ...vdomainaliases...vfilters......DoneConfiguring DNS......DoneRestarting apache......DoneChanging password for souser
    Password for souser has been changed
    Updating Authentication Databases...Updating ftp passwords for souser
    Ftp password files updated.
    Ftp vhost passwords synced
    ...DoneVerifying MX Records and Setting up Databases......DoneSetting up Proxy Subdomains......DoneBind reconfiguring on sapphire using rndc
    Sending Account Information......DoneSystem has 0 free ips.
    Running post creation scripts (/scripts/legacypostwwwacct, /scripts/postwwwacct, /scripts/postwwwacctuser)......Donewwwacct creation finished
    Setting up Domain Pointers......DoneSetting Reseller Privs......DoneAccount Creation Complete!!!...Account Creation Ok...Done"
        ["status"]=>
        string(1) "1"
        ["statusmsg"]=>
        string(19) "Account Creation Ok"
      }
    }
    SIMPLEXML OBJ:
    I'm trying to figure out how I would display the "rawout" data in simpleXML. The one with account info.

  5. #5
    Code Warrior
    /////////|||||\\\\\\\\\
    amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama's Avatar
    Join Date
    Aug 2007
    Location
    Pyramids st, Giza, Egypt
    Age
    21
    Posts
    8,182
    Blog Entries
    12

    Re: XML Result from PHP?

    the xml output is full with syntax errors, although you can make it work if you remove these parts from it:
    Code:
    QUERY: 
    https://127.0.0.1:2087/xml-api/createacct?username=souser&password=pass123&domain=thdomain.com 
    
    RAW XML:
    and remove the last part too:
    Code:
    object(SimpleXMLElement)#2 (1) { 
      ["result"]=> 
      object(SimpleXMLElement)#3 (4) { 
        ["options"]=> 
        object(SimpleXMLElement)#4 (14) { 
          ["ip"]=> 
          string(14) "174.132.240.50" 
          ["nameserver"]=> 
          string(10) "ns1.kh3.us" 
          ["nameserver2"]=> 
          string(10) "ns2.kh3.us" 
          ["nameserver3"]=> 
          object(SimpleXMLElement)#5 (0) { 
          } 
          ["nameserver4"]=> 
          object(SimpleXMLElement)#6 (0) { 
          } 
          ["nameservera"]=> 
          object(SimpleXMLElement)#7 (0) { 
          } 
          ["nameservera2"]=> 
          object(SimpleXMLElement)#8 (0) { 
          } 
          ["nameservera3"]=> 
          object(SimpleXMLElement)#9 (0) { 
          } 
          ["nameservera4"]=> 
          object(SimpleXMLElement)#10 (0) { 
          } 
          ["nameserverentry"]=> 
          object(SimpleXMLElement)#11 (0) { 
          } 
          ["nameserverentry2"]=> 
          object(SimpleXMLElement)#12 (0) { 
          } 
          ["nameserverentry3"]=> 
          object(SimpleXMLElement)#13 (0) { 
          } 
          ["nameserverentry4"]=> 
          object(SimpleXMLElement)#14 (0) { 
          } 
          ["package"]=> 
          string(7) "default" 
        } 
        ["rawout"]=> 
        string(1624) "Checking input data...System has 0 free ips. 
    ...DoneWWWAcct 12.1.0 (c) 1997-2008 cPanel, Inc.... 
    
    Dns Zone check is enabled. 
    +===================================+ 
    | New Account Info                  | 
    +===================================+ 
    | Domain: thdomain.com 
    | Ip: 174.132.240.50 (n) 
    | HasCgi: y 
    | UserName: souser 
    | PassWord: pass123 
    | CpanelMod: x3 
    | HomeRoot: /home 
    | Quota: 0 Meg 
    | NameServer1: ns1.kh3.us 
    | NameServer2: ns2.kh3.us 
    | NameServer3:  
    | NameServer4:  
    | Contact Email:  
    | Package: default 
    | Feature List: default 
    | Language: english 
    +===================================+ 
    ...DoneRunning pre creation script (/scripts/prewwwacct)......DoneAdding User...Removing Shell Access (n) 
    ...DoneCopying skel files from /home/kh3us/cpanel3-skel/ to /home/souser/......DoneAdding Entries to httpd.conf......DoneSetting up Mail & Local Domains...localdomains...valiases ...vdomainaliases...vfilters......DoneConfiguring DNS......DoneRestarting apache......DoneChanging password for souser 
    Password for souser has been changed 
    Updating Authentication Databases...Updating ftp passwords for souser 
    Ftp password files updated. 
    Ftp vhost passwords synced 
    ...DoneVerifying MX Records and Setting up Databases......DoneSetting up Proxy Subdomains......DoneBind reconfiguring on sapphire using rndc 
    Sending Account Information......DoneSystem has 0 free ips. 
    Running post creation scripts (/scripts/legacypostwwwacct, /scripts/postwwwacct, /scripts/postwwwacctuser)......Donewwwacct creation finished 
    Setting up Domain Pointers......DoneSetting Reseller Privs......DoneAccount Creation Complete!!!...Account Creation Ok...Done" 
        ["status"]=> 
        string(1) "1" 
        ["statusmsg"]=> 
        string(19) "Account Creation Ok" 
      } 
    } 
    SIMPLEXML OBJ:
    so the final output would look like this:
    Code:
    <createacct> 
      <result> 
        <options> 
          <ip>174.132.240.50</ip> 
          <nameserver>ns1.kh3.us</nameserver> 
          <nameserver2>ns2.kh3.us</nameserver2> 
          <nameserver3></nameserver3> 
          <nameserver4></nameserver4> 
          <nameservera></nameservera> 
          <nameservera2></nameservera2> 
          <nameservera3></nameservera3> 
          <nameservera4></nameservera4> 
          <nameserverentry></nameserverentry> 
          <nameserverentry2></nameserverentry2> 
          <nameserverentry3></nameserverentry3> 
          <nameserverentry4></nameserverentry4> 
          <package>default</package> 
        </options> 
        <rawout>Checking input data...System has 0 free ips. 
    ...DoneWWWAcct 12.1.0 (c) 1997-2008 cPanel, Inc.... 
    
    Dns Zone check is enabled. 
    +===================================+ 
    | New Account Info                  | 
    +===================================+ 
    | Domain: thdomain.com 
    | Ip: 174.132.240.50 (n) 
    | HasCgi: y 
    | UserName: souser 
    | PassWord: pass123 
    | CpanelMod: x3 
    | HomeRoot: /home 
    | Quota: 0 Meg 
    | NameServer1: ns1.kh3.us 
    | NameServer2: ns2.kh3.us 
    | NameServer3:  
    | NameServer4:  
    | Contact Email:  
    | Package: default 
    | Feature List: default 
    | Language: english 
    +===================================+ 
    ...DoneRunning pre creation script (/scripts/prewwwacct)......DoneAdding User...Removing Shell Access (n) 
    ...DoneCopying skel files from /home/kh3us/cpanel3-skel/ to /home/souser/......DoneAdding Entries to httpd.conf......DoneSetting up Mail &amp; Local Domains...localdomains...valiases ...vdomainaliases...vfilters......DoneConfiguring DNS......DoneRestarting apache......DoneChanging password for souser 
    Password for souser has been changed 
    Updating Authentication Databases...Updating ftp passwords for souser 
    Ftp password files updated. 
    Ftp vhost passwords synced 
    ...DoneVerifying MX Records and Setting up Databases......DoneSetting up Proxy Subdomains......DoneBind reconfiguring on sapphire using rndc 
    Sending Account Information......DoneSystem has 0 free ips. 
    Running post creation scripts (/scripts/legacypostwwwacct, /scripts/postwwwacct, /scripts/postwwwacctuser)......Donewwwacct creation finished 
    Setting up Domain Pointers......DoneSetting Reseller Privs......DoneAccount Creation Complete!!!...Account Creation Ok...Done</rawout> 
        <status>1</status> 
        <statusmsg>Account Creation Ok</statusmsg> 
      </result> 
    </createacct>
    if you dont want to remove the parts above you need to put them in tags

  6. #6
    Learning Programmer Ricardo-san will become famous soon enough
    Join Date
    Jan 2009
    Posts
    54

    Re: XML Result from PHP?

    Yeah, those sections of code are outputted by the debug function.
    So what exactly is causing the errors?

  7. #7
    Code Warrior
    /////////|||||\\\\\\\\\
    amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama's Avatar
    Join Date
    Aug 2007
    Location
    Pyramids st, Giza, Egypt
    Age
    21
    Posts
    8,182
    Blog Entries
    12

    Re: XML Result from PHP?

    leaving text without tags

  8. #8
    Learning Programmer Ricardo-san will become famous soon enough
    Join Date
    Jan 2009
    Posts
    54

    Re: XML Result from PHP?

    Sorry I'm really a newbie at XML.
    Could you specify what I should do...?

  9. #9
    Code Warrior
    /////////|||||\\\\\\\\\
    amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama is a splendid one to behold amrosama's Avatar
    Join Date
    Aug 2007
    Location
    Pyramids st, Giza, Egypt
    Age
    21
    Posts
    8,182
    Blog Entries
    12

    Re: XML Result from PHP?

    parts like this without tags:
    Code:
    QUERY: 
    https://127.0.0.1:2087/xml-api/createacct?username=souser&password=pass123&domain=thdomain.com 
    
    RAW XML:
    need to be fixed by:
    -not printing them in the first place
    or -wraping it with tags like
    Code:
    <QUERY> 
    https://127.0.0.1:2087/xml-api/createacct?username=souser&password=pass123&domain=thdomain.com 
    </QUERY>

  10. #10
    Learning Programmer Ricardo-san will become famous soon enough
    Join Date
    Jan 2009
    Posts
    54

    Re: XML Result from PHP?

    Still nothing...
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="style.xsl"?><QUERY>https://127.0.0.1:2087/xml-api/createacct?username=so3user&password=pass123&domain=th3sdomain.com</QUERY><RAW XML><createacct>
      <result>
        <options>
          <ip>174.132.240.50</ip>
          <nameserver>ns1.kh3.us</nameserver>
          <nameserver2>ns2.kh3.us</nameserver2>
          <nameserver3></nameserver3>
          <nameserver4></nameserver4>
          <nameservera></nameservera>
          <nameservera2></nameservera2>
          <nameservera3></nameservera3>
          <nameservera4></nameservera4>
          <nameserverentry></nameserverentry>
          <nameserverentry2></nameserverentry2>
          <nameserverentry3></nameserverentry3>
          <nameserverentry4></nameserverentry4>
          <package>default</package>
        </options>
        <rawout>Checking input data...System has 0 free ips.
    ...DoneWWWAcct 12.1.0 (c) 1997-2008 cPanel, Inc....
    
    Dns Zone check is enabled.
    +===================================+
    | New Account Info                  |
    +===================================+
    | Domain: th3sdomain.com
    | Ip: 174.132.240.50 (n)
    | HasCgi: y
    | UserName: so3user
    | PassWord: pass123
    | CpanelMod: x3
    | HomeRoot: /home
    | Quota: 0 Meg
    | NameServer1: ns1.kh3.us
    | NameServer2: ns2.kh3.us
    | NameServer3: 
    | NameServer4: 
    | Contact Email: 
    | Package: default
    | Feature List: default
    | Language: english
    +===================================+
    ...DoneRunning pre creation script (/scripts/prewwwacct)......DoneAdding User...Removing Shell Access (n)
    ...DoneCopying skel files from /home/kh3us/cpanel3-skel/ to /home/so3user/......DoneAdding Entries to httpd.conf......DoneSetting up Mail &amp; Local Domains...localdomains...valiases ...vdomainaliases...vfilters......DoneConfiguring DNS......DoneRestarting apache......DoneChanging password for so3user
    Password for so3user has been changed
    Updating Authentication Databases...Updating ftp passwords for so3user
    Ftp password files updated.
    Ftp vhost passwords synced
    ...DoneVerifying MX Records and Setting up Databases......DoneSetting up Proxy Subdomains......DoneBind reconfiguring on sapphire using rndc
    Sending Account Information......DoneSystem has 0 free ips.
    Running post creation scripts (/scripts/legacypostwwwacct, /scripts/postwwwacct, /scripts/postwwwacctuser)......Donewwwacct creation finished
    Setting up Domain Pointers......DoneSetting Reseller Privs......DoneAccount Creation Complete!!!...Account Creation Ok...Done</rawout>
        <status>1</status>
        <statusmsg>Account Creation Ok</statusmsg>
      </result>
    </createacct>
    
    <!-- Web Host Manager  (c) cPanel, Inc. 2008 http://cpanel.net/  Unauthorized copying is prohibited. -->
    </RAW XML>
    Btw, I set debug value to 0, so QUERY and RAW XML shouldn't have been showing up anyway...

+ Reply to Thread
Page 1 of 2
1 2 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. PHP 5 and OOP
    By Jordan in forum PHP Tutorials
    Replies: 11
    Last Post: 09-22-2008, 01:58 AM
  2. PHP 4 end of life announcement
    By Jordan in forum News
    Replies: 4
    Last Post: 08-30-2007, 09:55 AM
  3. Scripting Conflict Help
    By thunderbucks in forum Java Help
    Replies: 14
    Last Post: 11-02-2006, 08:24 AM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts