I have written this code to generate this XML structure, but for some reason it doesn't seems to be working. It throws the error :- Undefined variable: operationtype in C:\wamp\www\sms-gateway\dev\testxml.php on line 11 and Call to a member function appendChild() on a non-object in C:\wamp\www\sms-gateway\dev\testxml.php on line 11
I'm using php's DOMDocument library, which I don;t have any experience with. Here's what I need to generate :-
Here's my code :-
function gen_xml($number,$message,$smssender)
{
/* create a dom document with encoding utf8 */
$domtree = new DOMDocument('1.0', 'UTF-8');
/* create the root element of the xml tree */
$xmlRoot = $domtree->createElement("sms-teknik");
/* append it to the document created */
$xmlRoot = $domtree->appendChild($xmlRoot);
$operationtype->appendChild($domtree->createElement('operationtype','0'));
$flash->appendChild($domtree->createElement('flash','0'));
$multisms->appendChild($domtree->createElement('multisms','0'));
$maxmultisms->appendChild($domtree->createElement('maxmultisms','0'));
$compresstext->appendChild($domtree->createElement('compresstext','0'));
$smssender->appendChild($domtree->createElement('smssender',$smssender));
$deliverystatustype->appendChild($domtree->createElement('deliverystatustype','0'));
$usereplynumber->appendChild($domtree->createElement('usereplynumber','0'));
$usereplyforwardtype->appendChild($domtree->createElement('usereplyforwardtype','0'));
$usee164->appendChild($domtree->createElement('usee164','0'));
$item=$domtree->createElement("items");
$item = $domtree->appendChild($item);
$recipient = $domtree->createElement("recipient");
$recipient = $domtree->appendChild($recipient);
$orgaddress->appendChild($domtree->createElement('orgaddress',$number));
echo $domtree->saveXML();
}
Any suggestions / help would be greatly appreciated.
No comments:
Post a Comment