function testXmlQuery($username,$password,$constraints)
    // transactionFields has all of the fields we want to validate
    // in the transaction tag in the XML output
    $transactionFields = array(





    // actionFields is used to validate the XML tags in the
    // action element
     $actionFields = array(

    $postStr='username='.$username.'&password='.$password. $constraints;
    $url="". $postStr;
    curl_setopt($mycurl, CURLOPT_URL, $url);
    curl_setopt($mycurl, CURLOPT_RETURNTRANSFER, 1);

    $testXmlSimple= new SimpleXMLElement($responseXML);

    if (!isset($testXmlSimple->transaction)) {
            throw new NmExUser('No transactions returned');

    $transNum = 1;
    foreach($testXmlSimple->transaction as $transaction) {
        foreach ($transactionFields as $xmlField) {
            if (!isset($transaction->{$xmlField}[0])){
                throw new NmExUser('Error in transaction_id:'. $transaction->transaction_id[0] .' id  Transaction tag is missing  field ' . $xmlField);
        if (!isset ($transaction->action)) {
            throw new nmExUser('Error, Action tag is missing from transaction_id '. $transaction->transaction_id[0]);

        $actionNum = 1;
        foreach ($transaction->action as $action){
            foreach ($actionFields as $xmlField){
                if (!isset($action->{$xmlField}[0])){
                    throw new NmExUser('Error with transaction_id'.$transaction->transaction_id[0].'
                                        Action number '. $actionNum . ' Action tag is missing field ' . $xmlField);


try {

    $constraints = "&action_type=sale&start_date=20060913";
    $result = testXmlQuery('test123','test1234',$constraints);
    print "Success.\n";

} catch (Exception $e) {