Page 1 of 1

XML Requests

Posted: Thu Sep 04, 2008 4:15 am
by Sephirangel
Im currently developing a front-end client system for a reseller account using XML RPC.

The function below creates an XML request to send to the server (this is an example function):

Code: Select all

function construct_xml ($domain) { //returns XML request using user-inputted data eg: domain supplied for avaliability checking
    return <<<XML
    <?xml version='1.0' encoding='utf-8' ?>
        <rpc module='Domain' method='Availability' version='1.0'> 
            <auth> 
                <username>foo</username> 
                <password>bar</password> 
            </auth> 
            <domain datatype='domain_name'>$domain</domain>
        </rpc> 
    XML;
}
The code brings up an "unexpected $end" error on the line "<?xml version='1.0' encoding='utf-8' ?>". This is due to the "?>" of the XML declaration.
Any way to get around this using the same <<<XML return method? If not then i guess constructing and returning a string will have to do!

Thanks in advance

Re: XML Requests

Posted: Thu Sep 04, 2008 11:28 am
by andyhoneycutt
use quoted strings and escape things you need as literals instead of trying to do an inline text block.

Re: XML Requests

Posted: Thu Sep 04, 2008 5:54 pm
by Sephirangel
yeh im using it in string style now. Would of been nice to use the <<<XML method, ah well, thanks!