Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $xml = <<<EOD
- <?xml version="1.0" encoding="UTF-8"?>
- <SENDBATCH user='username' password='password' application='50' reply='EMAIL:[email protected]'>
- This is a test
- <SMSLIST>
- <SMS_SEND to='256791040262' uid='1'/>
- <SMS_SEND to='256754819815' uid='2'/>
- </SMSLIST>
- <SMSGROUP>
- <SMS_SEND to='256791234567' uid='3'/>
- <SMS_SEND to='256754819814' uid='4'/>
- </SMSGROUP>
- </SENDBATCH>
- EOD;
- $xmlObject = new SimpleXMLElement($xml);
- //root name
- $rootnode = $xmlObject->getName();
- //children count
- $children_no = count($xmlObject->children());
- //get the message
- $msg = $xmlObject->SENDBATCH;
- //get attributes of the root node
- foreach ($xmlObject->attributes() as $key=>$value) {
- switch ($key) {
- case 'user':
- $user = $value[0];
- break;
- case 'password':
- $password = $value[0];
- break;
- case 'application':
- $application = $value[0];
- break;
- case 'reply':
- $reply = $value[0];
- break;
- default:
- ;
- break;
- }//close switch
- }
Advertisement
Add Comment
Please, Sign In to add comment