INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

E-mail*
Handle

Password
Verify P'word
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Member Feedback

"...Congratulations on a brilliant idea and a great site..."

Geography

Where in the world do Tek-Tips members come from?

 PHP - Read XML variable from Stream & redirect page

goker (TechnicalUser)
27 Oct 09 6:57
Hi,

I've got a PHP file that sends XML code "on the fly" to an external webpage which then replys with it's own XML data stream.

I've saved to contects of the stream to a XML file and echoed the contents , but what I would like to do it interrogate the incoming stream "on the fly" and redirect the browser to a webpage, depending on certain variable values.

The SEND and ECHO code looks like this :-

   req =& new HTTP_Request($url);

   $req->setMethod(HTTP_REQUEST_METHOD_POST);

   $req->addHeader('POST',' /webpage.asmx HTTP/1.1');

   $req->addHeader('Host','ws.webpage.co.uk');

   $req->addHeader('Content-Type','text/xml; charset=utf-8');

   $req->addHeader('ContentLength',strlen($xml_document));

   $req->addHeader('SOAPAction','"http://webpage.co.uk/search/V2.0/PerformCheck"');

   $req->SetBody($xml_document);

   $req->sendRequest();

   $xmlResponse = simplexml_load_string($req->getResponseBody());

   echo $xmlResponse -> asXML();

The response looks like :-

     <?xml version="1.0" encoding="utf-8" ?>
   - <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org
/soap/envelope/" xmlns:xsi="http://www.w3.org
/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org
/2001/XMLSchema">
   - <soap:Body>
   - <PerformMLCheckResponse xmlns="webpage">
   - <CallResponse>
     <AcrService>checking</AcrService>
     <AcrSearchId>myid</AcrSearchId>
     <AcrReference>refcode</AcrReference>
     <AcrIntReference>externalcode</AcrIntReference>
     <AcrExtReference>externalcode</AcrExtReference>
     <AcrDateTime>2009-10-25T15:15:26.865625+00:00</AcrDateTime>
     <AcrAccept>Y</AcrAccept>
     <AcrFormatted>Y</AcrFormatted>
     <AcrXmlDetail>Y</AcrXmlDetail>
   - <AcrResponseDetail>
   - <AcdElectoral>
     <AerUsed>Y</AerUsed>
     <AerValid>Y</AerValid>
     <AerPafMatch>Y</AerPafMatch>
     <AerForename>David</AerForename>
     <AerOthernames />
     <AerSurname>Brent</AerSurname>
   - <AerAddress>
     <AadAbode />
     <AadBuilding>22</AadBuilding>
     <AadStreet>test town</AadStreet>
     <AadLocality />
     <AadPostTown>test street</AadPostTown>
     <AadPostcode>GU99 1AP</AadPostcode>
     </AerAddress>
     <AerStartDate>1996-10-28</AerStartDate>
     <AerMonths>110</AerMonths>
     <AerOptOut>Y</AerOptOut>
     <AerPriorFlag>N</AerPriorFlag>
     </AcdElectoral>
   - <AcdCreditHistory>
     <ChyUsed>Y</ChyUsed>
     <ChyType>superuser</ChyType>

I was trying to inplement some code along the lines of

$type = $xmlResponse->ChyType
$Used = $xmlResponse->ChyUsed

if($xmlResponse::$chyType == $type &&
$xmlResponse::$chyused == $used) {
   goto www.yahoo.uk
  }
   else {
  if($xmlResponse::$chyType NOT EQUAL $type &&
$xmlResponse::$chyused NOT EQUAL $used)
     goto www.google.co.uk
  }
else {
  if($xmlResponse::$chyType == $type &&
$xmlResponse::$chyused NOT EQUAL $used)
     goto www.ask.co.uk
  }
else {
  if($xmlResponse::$chyType NOT EQUAL $type &&
$xmlResponse::$chyused == $used)
     goto www.bing.co.uk
  }

Could someone help / pont me in the right direcetion please ?

Thanks
Helpful Member!jpadie (TechnicalUser)
27 Oct 09 9:54
goto www.bing.co.uk

CODE

header('Location: www.bing.co.uk');
Helpful Member!jpadie (TechnicalUser)
27 Oct 09 9:55
and NOT EQUAL should be written as

CODE

!==
goker (TechnicalUser)
27 Oct 09 10:58
HI jpadie,

thanks for the coding heads up. Like I said ,im a complete Noob when it comes to PHP.
I just need to get the rest working now.
 
Helpful Member!jpadie (TechnicalUser)
27 Oct 09 11:29
what is not working?
goker (TechnicalUser)
27 Oct 09 12:09
Honesty, I dont know. NOOB ALERT :)

My coding (the relvant stuff anyway)looks like this :-

$CrqDocName=str_replace('%',substr(microtime(),2,7),date('Y-m-d\TH-i-s-%O'));
$CrqDocName=substr($CrqDocName,0,-2).'-'.substr($CrqDocName,-2);
$urlDoc = $CrqDocName;
$results_path_dir  = "output/";
$results_path_dir .= $urlDoc ."-RESULTS.xml";
$url = "http://ws.website.co.uk/Search.asmx" ;

$xml_document .=  "<Title>";
$xml_document .=  $title;
$xml_document .=  "</Title>";

$req =& new HTTP_Request($url);
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addHeader('POST',' /Search.asmx HTTP/1.1');
$req->addHeader('Host','ws.website.co.uk');
$req->addHeader('Content-Type','text/xml; charset=utf-8');
$req->addHeader('ContentLength',strlen($xml_document));
$req->addHeader('SOAPAction','"http://website.co.uk/search/V2.0/PerformCheck"');
$req->SetBody($xml_document);
$req->sendRequest();

$results=$req->getResponseBody();
$xmlResponse = simplexml_load_string($req->getResponseBody());

$fh = fopen($results_path_dir, "r") or exit("Unable to open file!");

$file = file_get_contents($results_path_dir);
echo $file;

$type="n";
$used="n";

  if($file::$chyType == $type && $file::$chyused == $used) {
   header('Location: www.yahoo.co.uk.co.uk');
  }
   else {
  if($file::$chyType !== $type && $file::$chyused !== $used)
     header('Location: www.google.co.uk');
  }
else {
  if($file::$chyType == $type && $file::$chyused !== $used)
     header('Location: www.ask.co.uk');
  }
else {
  if($file::$chyType !== $type && $file::$chyused == $used)
     header('Location: www.bing.co.uk');
  }

the repesonse, looks like my original post ( just snipped down to save space ).

I want to load the streams content directly into a variable, rather than into a file first, then load the file nto a variable like i'm (hopefully) doing at the moment.
I then want to interogate 2 specific values and depending on them, point them to webpages (as per you pervious post ~( thanks again )).

I'm getting "twice colon" error messages at the moment, so that will be the "$file::$chyType == $type && $file::$chyused == $used" lines , but I dont know what code I need to use to get want i want to happen ie :-

 Load XML data stream into variable
 Search variable for 1st item of data
 Save data to var1
 Search variable for 2nd item of data
 save data to var2
 intergate var1 and var2 and repoint browser accordingly.

If there is a better / easier way, I'm all ears ;)

Thank jpadie
Helpful Member!jpadie (TechnicalUser)
27 Oct 09 12:20
despite the fact that i think your variable comparisons are a bit odd (as per your original post), you are misusing their scope operators.

CODE

$file::$chyType == $type && $file::$chyused == $used

should be

CODE

$file->chyType == $type && $file->chyused == $used
goker (TechnicalUser)
27 Oct 09 12:42
HI, Thanks again.
I thought i need -> instead of ::, but scouring the net for solutions, that method seems to pop up the most.

I get now

Parse error: syntax error, unexpected T_ELSE in /test/d2xml.php on line 308

Should the following code be IF...THEN...ELSE?(line 308 is the line that starts "header('Location:www.google.co.uk')):-

  if($file->$chyType == $type && $file->$chyused == $used) {
   header('Location: www.yahoo.co.uk.co.uk');
  }
   else {
  if($file->$chyType !== $type && $file->$chyused !== $used)
     header('Location: www.google.co.uk');
  }
else {
  if($file->$chyType == $type && $file->$chyused !== $used)
     header('Location: www.ask.co.uk');
  }
else {
  if($file->$chyType !== $type && $file->$chyused == $used)
     header('Location: www.bing.co.uk');
  }

By the way, is my code of loading the file into a variable correct? I just want to make sure that I'm not performing queries on blank information.

Thanks for your help again
Helpful Member!jpadie (TechnicalUser)
27 Oct 09 13:16
i can't test your xml get as the relevant web information is not there.

you have your curly braces unbalanced.  try this instead

CODE

if($file->$chyType == $type && $file->$chyused == $used) {
    header('Location: www.yahoo.co.uk');
} elseif ($file->$chyType != $type && $file->$chyused != $used) {
    header('Location: www.google.co.uk');
} elseif ($file->$chyType == $type && $file->$chyused != $used) {
    header('Location: www.ask.co.uk');
} else{
    header('Location: www.bing.co.uk');
}
goker (TechnicalUser)
27 Oct 09 15:40
Hi,
I've made those changes, but I now get

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

Only one top level element is allowed in an XML document. Error processing resource 'http://www.accountstoyou.co.uk/hidden/...

<AcrCallFailed>N</AcrCallFailed><AcrIDFailed>N</AcrIDFailed></CallResponse></PerformMLCheck...
eft:1em;text-indent:-2em">   

what did i do wrong ?
Helpful Member!jpadie (TechnicalUser)
27 Oct 09 16:44
difficult to answer without you providing the actual code you are using.
goker (TechnicalUser)
28 Oct 09 4:16
Hi jpaide

Here is the, sanitized, code that I'm using :-

<?php
set_include_path('.:/ /htdocs/PEAR/');

require_once " /htdocs/PEAR/HTTP/Request.php";

require_once /htdocs/PEAR/PEAR.php";

PEAR::setErrorHandling(PEAR_ERROR_DIE);

if(isset($_POST['create_xml'])){

/* All Links data from the form is now being stored in variables in string format  */

        $firstName = $_POST['firstName'];

        $lastName = $_POST['lastName'];

        $address1 = $_POST['address1'];
        
        $address2 = $_POST['address2'];
        
        $streetnumber = $_POST['streetnumber'];
        
        $title = $_POST['title'];

    $postcode = $_POST['postcode'];
       
    $country = $_POST['country'];

    $since = $_POST['since'];

    $DoBday = $_POST['DoBday'];

    $DoBmonth = $_POST['DoBmonth'];

    $DoByr = $_POST['DoByr'];

    $passdrive = $_POST['passdrive'];

    $refno = $_POST['refno'];

       $CrqDateTime=str_replace('%',substr(microtime(),2,7),date('Y-m-d\TH:i:s.%O'));

       $CrqDateTime=substr($CrqDateTime,0,-2).':'.substr($CrqDateTime,-2);
       
       $CrqDocName=str_replace('%',substr(microtime(),2,7),date('Y-m-d\TH-i-s-%O'));

       $CrqDocName=substr($CrqDocName,0,-2).'-'.substr($CrqDocName,-2);

       $urlDoc = $CrqDocName;

       $DoBtime = "T00:00:00.0000000+01:00";

       $url = "http://ws.website.co.uk/Search.asmx" ;
       
       $CrqTestRequest = "Test";

       $CrqService = "searching";

       $CrqCompanyID = "me";
       
       $CrqUserID = "MeAPI";

       $CrqSearchID = "ID0001";
       
       $CrqPassword = "abc1234";
       
       $CrqClientRef = "TESTREF0001";
       
       $xmlBeg1 = '<?xml version="1.0" encoding="utf-8"?>';

       $xmlBeg2 = '<soap:Envelope xmlns:xds="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-

instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
       
       $xmlBeg4 = '<PerformCheck xmlns="http://website.co.uk/search/V2.0">';

       $CrqIntegratorID ="glo1";

        $xml_document=  $xmlBeg1;

        $xml_document .=  $xmlBeg2;

        $xml_document .=  "<soap:Body>";

        $xml_document .=  $xmlBeg4;

        $xml_document .=  "<CallRequest>";

        $xml_document .=  "<CrqIntegratorId>";

        $xml_document .=  $CrqIntegratorID;
        
        $xml_document .=  "</CrqIntegratorId>";

        $xml_document .=  "<CrqTestRequest>";

        $xml_document .=  $CrqTestRequest;
     
        $xml_document .=  "</CrqTestRequest>";

        $xml_document .=  "<CrqDateTime>";

        $xml_document .=  $CrqDateTime;

        $xml_document .=  "</CrqDateTime>";

        $xml_document .=  "<CrqService>";

        $xml_document .=  $CrqService;

        $xml_document .=  "</CrqService>";

        $xml_document .=  "<CrqCompanyID>";

        $xml_document .=  $CrqCompanyID;
     
        $xml_document .=  "</CrqCompanyID>";

        $xml_document .=  "<CrqUserID>";

        $xml_document .=  $CrqUserID;
     
        $xml_document .=  "</CrqUserID>";

        $xml_document .=  "<CrqPassword>";

        $xml_document .=  $CrqPassword;
     
        $xml_document .=  "</CrqPassword>";

        $xml_document .=  "<CrqSearchId>";

        $xml_document .=  $CrqSearchID;
     
        $xml_document .=  "</CrqSearchId>";

        $xml_document .=  "<CrqClientRef>";

        $xml_document .=  $CrqClientRef;
     
        $xml_document .=  "</CrqClientRef>";
        
        $xml_document .=  "<CrqApplicant>";
        
        $xml_document .=  "<AptName>";
        
        $xml_document .=  "<Surname>";
        
        $xml_document .=  $lastName;
        
        $xml_document .=  "</Surname>";
        
        $xml_document .=  "<Forename>";
        
        $xml_document .=  $firstName;
        
        $xml_document .=  "</Forename>";
       
        $xml_document .=  "<Title>";
        
        $xml_document .=  $title;
        
        $xml_document .=  "</Title>";

        $xml_document .=  "</AptName>";
        
        $xml_document .=  "<AptAddress>";
        
        $xml_document .=  "<AadBuilding>";
        
        $xml_document .=  $streetnumber;
        
        $xml_document .=  "</AadBuilding>";
        
        $xml_document .=  "<AadStreet>";
        
        $xml_document .=  $address1;
        
        $xml_document .=  "</AadStreet>";
        
        $xml_document .=  "<AadPostTown>";
        
        $xml_document .=  $address2;
        
        $xml_document .=  "</AadPostTown>";
        
        $xml_document .=  "<AadPostcode>";
        
        $xml_document .=  $postcode;
        
        $xml_document .=  "</AadPostcode>";
        
        $xml_document .=  "</AptAddress>";

        $xml_document .= "<AptDOB>";

        $xml_document .= "<Date>";

        $xml_document .= $DoByr."-". $DoBmonth."-". $DoBday. $DoBtime;

        $xml_document .= "</Date>";
       
        $xml_document .= "</AptDOB>";
       
        $xml_document .=  "</CrqApplicant>";
                
        $xml_document .=  "</CallRequest>";
                  
        $xml_document .=  "</PerformMLCheck>";
    
        $xml_document .=  "</soap:Body>";
        
        $xml_document .=  "</soap:Envelope>";

        $doc_document= $title;

        $doc_document .= $firstName;

        $doc_document .= $lastName;

        $doc_document .= $streetnumber;
    
    $doc_document .= $address1;

    $doc_document .= $address2;

    $doc_document .= $postcode;

    $doc_document .= $country;

        $path_dir = "output/";

    $doc_path_dir  = "output/";

        $results_path_dir  = "output/";

        $path_dir .=   $urlDoc .".xml";

    $doc_path_dir .= $urlDoc .".doc";

    $results_path_dir .= $urlDoc ."-RESULTS.xml";

/* START Send RAW data */

$req =& new HTTP_Request($url);

$req->setMethod(HTTP_REQUEST_METHOD_POST);

$req->addHeader('POST',' /Search.asmx HTTP/1.1');

$req->addHeader('Host','ws.website.co.uk');

$req->addHeader('Content-Type','text/xml; charset=utf-8');

$req->addHeader('ContentLength',strlen($xml_document));

$req->addHeader('SOAPAction','"http://website.co.uk/search/V2.0/PerformCheck"');

$req->SetBody($xml_document);

$req->sendRequest();

$results=$req->getResponseBody();

$xmlResponse = simplexml_load_string($req->getResponseBody());
$xmlresults = SimpleXml_Load_String($req->getResponseBody());
$ChyType = (string)$xmlresults->CallResponse->AcdCreditHistory->ChyType;

//echo $xmlResponse -> asXML();

/* END Send RAW data */


/* Data in Variables ready to be written to an XML file */

$fp = fopen($path_dir,'w');

            $write = fwrite($fp,$xml_document);
fclose($fp);

/* Data in Variables ready to be written to an DOC file */

$fp = fopen($doc_path_dir,'w+');

            $write = fwrite($fp,$doc_document);
fclose($fp);

/* Response to be written to an XMl file */

$fp = fopen($results_path_dir,'w+');

            $write = fwrite($fp,$results);
fclose($fp);


$fh = fopen($results_path_dir, "r") or exit("Unable to open file!");

$file = file_get_contents($results_path_dir);
echo $file;

$type = "n";
$used = "n";

if($file->$chyType == $type && $file->$chyused == $used) {
    header('Location: www.yahoo.co.uk');
} elseif ($file->$chyType != $type && $file->$chyused != $used) {
    header('Location: www.google.co.uk');
} elseif ($file->$chyType == $type && $file->$chyused != $used) {
    header('Location: www.ask.co.uk');
} else{
    header('Location: www.bing.co.uk');
}


if (PEAR::isError($result)) {
    echo $result->getMessage();
} else {

    
}


}


?>


Thanks
Helpful Member!jpadie (TechnicalUser)
28 Oct 09 5:08
i wasn't clear.  the url and website credentials are missing.  therefore i cannot test the solution end to end.  

but there is no need to store the xml output in a file in order to use it as a variable.  your data is already in the $xmlResponse variable as a nice object. the ChyType and ChyUsed should be in $xmlResponse->CallResponse-> AcdCreditHistory->ChyType and $xmlResponse->CallResponse-> AcdCreditHistory->ChyUsed respectively.

so you would rewrite this code

CODE

$xmlresults = SimpleXml_Load_String($req->getResponseBody());
$ChyType = (string)$xmlresults->CallResponse->AcdCreditHistory->ChyType;

//echo $xmlResponse -> asXML();

/* END Send RAW data */


/* Data in Variables ready to be written to an XML file */

$fp = fopen($path_dir,'w');

            $write = fwrite($fp,$xml_document);
fclose($fp);

/* Data in Variables ready to be written to an DOC file */

$fp = fopen($doc_path_dir,'w+');

            $write = fwrite($fp,$doc_document);
fclose($fp);

/* Response to be written to an XMl file */

$fp = fopen($results_path_dir,'w+');

            $write = fwrite($fp,$results);
fclose($fp);


$fh = fopen($results_path_dir, "r") or exit("Unable to open file!");

$file = file_get_contents($results_path_dir);
echo $file;

$type = "n";
$used = "n";

if($file->$chyType == $type && $file->$chyused == $used) {
    header('Location: www.yahoo.co.uk');
} elseif ($file->$chyType != $type && $file->$chyused != $used) {
    header('Location: www.google.co.uk');
} elseif ($file->$chyType == $type && $file->$chyused != $used) {
    header('Location: www.ask.co.uk');
} else{
    header('Location: www.bing.co.uk');
}


if (PEAR::isError($result)) {
    echo $result->getMessage();
} else {

    
}


}


?>

as follows

CODE

$xmlResults = SimpleXml_Load_String($req->getResponseBody());
$ChyType = (string)$xmlResults->CallResponse->AcdCreditHistory->ChyType;
$ChyUsed = (string) $xmlResults->CallResponse->AcdCreditHistory->ChyUsed;

$type = "n";
$used = "n";
if (PEAR::isError($result)) {
    echo $result->getMessage();
    die();
} else {


if($ChyType == $type && $ChyUsed == $used) {
    header('Location: www.yahoo.co.uk');
} elseif ($ChyType != $type && $ChyUsed != $used) {
    header('Location: www.google.co.uk');
} elseif ($ChyType == $type && $ChyUsed != $used) {
    header('Location: www.ask.co.uk');
} else{
    header('Location: www.bing.co.uk');
}
} //end pear::iserror test
?>

if you actively wish to store the xml object in a text document then you would need to serialize it

CODE

file_put_contents($myFile, serialize($xmlResponse));

and to reuse the object later

CODE

$myObj = unserialize(file_get_contents($myFile));
goker (TechnicalUser)
29 Oct 09 4:14
Jpadie.... YOUR A STAR.

That seems to be working exactly how I wanted it to.
Tek-Tips and it's members prove their worth they weight in gold smile

I change a couple of lines of code as the redirects when opening up the pages properly. So they now look like :-

if($ChyType == $type && $ChyUsed == $used) {
    header('Location: http://www.yahoo.co.uk');
} elseif ($ChyType != $type && $ChyUsed != $used) {
    header('Location: http://www.google.co.uk');
} elseif ($ChyType == $type && $ChyUsed != $used) {
    header('Location: http://www.ask.co.uk');
} else{
    header('Location: http://www.bing.co.uk');
}

Thanks again
Helpful Member!jpadie (TechnicalUser)
29 Oct 09 5:53
no worries.  glad you're up and working.
goker (TechnicalUser)
29 Oct 09 8:05
hi,
bit of a problem, that i hope you can help with.
All searches are bring up the google page. Any ideas why ?

$pportfraud = (string)$xmlresults->CallResponse->AcrResponseDetail->AcdWarnPassportFraud;
//$ChyUsed = (string)$xmlresults->CallResponse->AcdCreditHistory->ChyUsed;
$gone = (string)$xmlresults->CallResponse->AcrResponseDetail->AcdWarnGoneAway;

$ppfraud = "Y";
$goneaway = "N";

if($pportfraud == $ppfraud && $gone == $goneaway) {
    header('Location: http://www.yahoo.co.uk');
} elseif ($pportfraud != $ppfraud && $gone != $goneaway) {
    header('Location: http://www.google.com');
} elseif ($pportfraud == $ppfraud && $gone != $goneaway) {
    header('Location: http://www.ask.co.uk');
} else{
    header('Location: http://www.bing.co.uk');
}

    
}



The response data look like :-

- <CallResponse>
  <AcrService>SEARCHING</AcrService>
  <AcrSearchId>MYID</AcrSearchId>
  <AcrReference>TESTREF0001</AcrReference>
  <AcrIntReference>00gffgfg000393:MtEtD-8CBjjj7D-d6E47-Myyyd8Ce-GAN46G</AcrIntReference>
  <AcrExtReference>0000hdfhdhdfhfd0393:MtEssddsdtD-8CB7D-deyeyey6E47-Md8Ce-GANreyry46G</AcrExtReference>
  <AcrDateTime>2009-10-28T15:12:23.6625+00:00</AcrDateTime>
  <AcrAccept>Y</AcrAccept>
  <AcrFormatted>Y</AcrFormatted>
  <AcrXmlDetail>Y</AcrXmlDetail>
- <AcrResponseDetail>
+ <AcdElectoral>
  <AerUsed>Y</AerUsed>
  <AerValid>Y</AerValid>
  <AerPafMatch>Y</AerPafMatch>
  <AerForename>madeup</AerForename>
  <AerOthernames />
  <AerSurname>name</AerSurname>
+ <AerAddress>
  <AadAbode />
  <AadBuilding>22</AadBuilding>
  <AadStreet>Test street</AadStreet>
  <AadLocality />
  <AadPostTown>test town</AadPostTown>
  <AadPostcode>GU99 9AB</AadPostcode>
  </AerAddress>
  <AerStartDate>1996-10-28</AerStartDate>
  <AerMonths>110</AerMonths>
  <AerOptOut>Y</AerOptOut>
  <AerPriorFlag>N</AerPriorFlag>
  </AcdElectoral>
+ <AcdCreditHistory>
  <ChyUsed>Y</ChyUsed>
  <ChyType>BankruptcyOrder</ChyType>
  <ChyCourt>GUILDFORD</ChyCourt>
  <ChyCaseNumber />
  <ChyTitle>MR</ChyTitle>
  <ChyForename>madeup</ChyForename>
  <ChyOthernames />
  <ChySurname>name</ChySurname>
  <ChyAddress>22;TEST STREET;TEST TOWN;GU99 9AB</ChyAddress>
  <ChyLess1Year>Y</ChyLess1Year>
  </AcdCreditHistory>
+ <AcdCreditHistory>
  <ChyUsed>Y</ChyUsed>
  <ChyType>CCJ</ChyType>
  <ChyCourt>READING</ChyCourt>
  <ChyCaseNumber>XX895ZZ</ChyCaseNumber>
  <ChyTitle>MR</ChyTitle>
  <ChyForename>mmadeup</ChyForename>
  <ChyOthernames />
  <ChySurname>name</ChySurname>
  <ChyAddress>22 TEST STREET TEST TOWN GU99 9AB</ChyAddress>
  <ChyLess1Year>N</ChyLess1Year>
  </AcdCreditHistory>
+ <AcdCreditHistory>
  <ChyUsed>N</ChyUsed>
  <ChyType>CCJ</ChyType>
  <ChyCourt>GUILDFORD</ChyCourt>
  <ChyCaseNumber>XX861ZZ</ChyCaseNumber>
  <ChyTitle>MR</ChyTitle>
  <ChyForename>madeup</ChyForename>
  <ChyOthernames />
  <ChySurname>name</ChySurname>
  <ChyAddress>22 TEST STREET TEST TOWN GU99 9AB</ChyAddress>
  <ChyLess1Year>Y</ChyLess1Year>
  </AcdCreditHistory>
+ <AcdShare>
  <AsiGroupType>LoanAndInstalmentCredit</AsiGroupType>
  <AsiLess1Year>N</AsiLess1Year>
  <AsiUsed>N</AsiUsed>
  <AsiStatus>NormalAccountHolder</AsiStatus>
  <AsiTitle>Mr</AsiTitle>
  <AsiForename>madeup</AsiForename>
  <AsiOthernames>strange</AsiOthernames>
  <AsiSurname>name</AsiSurname>
  <AsiAddress>22 Test street test town</AsiAddress>
  <AsiPostcode>GU99 9AB</AsiPostcode>
  <AsiDOB>1973-04-30</AsiDOB>
  </AcdShare>
+ <AcdShare>
  <AsiGroupType>Mortgage</AsiGroupType>
  <AsiLess1Year>N</AsiLess1Year>
  <AsiUsed>N</AsiUsed>
  <AsiStatus>NormalAccountHolder</AsiStatus>
  <AsiTitle>Mr</AsiTitle>
  <AsiForename>madeup</AsiForename>
  <AsiOthernames />
  <AsiSurname>name</AsiSurname>
  <AsiAddress>22 Test street test town</AsiAddress>
  <AsiPostcode>GU99 9AB</AsiPostcode>
  <AsiDOB>1973-05-30</AsiDOB>
  </AcdShare>
+ <AcdShare>
  <AsiGroupType>RevolvingCreditBudget</AsiGroupType>
  <AsiLess1Year>Y</AsiLess1Year>
  <AsiUsed>N</AsiUsed>
  <AsiStatus>NormalAccountHolder</AsiStatus>
  <AsiTitle>Mr</AsiTitle>
  <AsiForename>madeup</AsiForename>
  <AsiOthernames />
  <AsiSurname>name</AsiSurname>
  <AsiAddress>22 Test street test town</AsiAddress>
  <AsiPostcode>GU99 9AB</AsiPostcode>
  <AsiDOB>1973-05-30</AsiDOB>
  </AcdShare>
+ <AcdFtse>
  <AfiUsed>N</AfiUsed>
  <AfiTitle>MR</AfiTitle>
  <AfiForename>madeup</AfiForename>
  <AfiSurname>name</AfiSurname>
+ <AfiAddress>
  <AadAbode />
  <AadBuilding>22</AadBuilding>
  <AadStreet>Test street</AadStreet>
  <AadLocality />
  <AadPostTown>test town</AadPostTown>
  <AadPostcode>GU99 9AB</AadPostcode>
  </AfiAddress>
  <AfiCompanies>RUSTY CAR AUCTIONS, CRUMBLY GRAVESTONES, GENERALLY DECREPIT STUFF LTD, THINGS THAT MAKE THIS LIST WRAP AROUND PLC, ANOTHER ONE FOR LUCK LTD</AfiCompanies>
  </AcdFtse>
+ <AcdPriorSearches>
  <ApsSearchDate>2009-10-24</ApsSearchDate>
  <ApsSearchId>{28hgvfgr9B40FA-6E065654A-4554644A1-8ghghAh49-E6565F7C15D3512D}</ApsSearchId>
  <ApsSearchPurpose>MoneyLaundering</ApsSearchPurpose>
  <ApsCompanyType>BankingAndFinancialServices</ApsCompanyType>
  <ApsTitle>MR</ApsTitle>
  <ApsForename>madeup</ApsForename>
  <ApsOthernames />
  <ApsSurname>name</ApsSurname>
+ <ApsAddress>
  <AadAbode />
  <AadBuilding>22</AadBuilding>
  <AadStreet>Test street</AadStreet>
  <AadLocality />
  <AadPostTown>test town</AadPostTown>
  <AadPostcode>GU99 9AB</AadPostcode>
  </ApsAddress>
  <ApsSearchAdrMatch>Y</ApsSearchAdrMatch>
  <ApsDOB>1973-04-30</ApsDOB>
  </AcdPriorSearches>
+ <AcdPriorSearches>
  <ApsSearchDate>2009-10-23</ApsSearchDate>
  <ApsSearchId>{D8hghg15407D-0EBAjjjj-433333D0B-B76767D6C-Amjhj32A0F5DA1C1}</ApsSearchId>
  <ApsSearchPurpose>MoneyLaundering</ApsSearchPurpose>
  <ApsCompanyType>BankingAndFinancialServices</ApsCompanyType>
  <ApsTitle>MR</ApsTitle>
  <ApsForename>madeup</ApsForename>
  <ApsOthernames />
  <ApsSurname>name</ApsSurname>
- <ApsAddress>
  <AadAbode />
  <AadBuilding>22</AadBuilding>
  <AadStreet>Test street</AadStreet>
  <AadLocality />
  <AadPostTown>test town</AadPostTown>
  <AadPostcode>GU99 9AB</AadPostcode>
  </ApsAddress>
  <ApsSearchAdrMatch>Y</ApsSearchAdrMatch>
  <ApsDOB>1973-04-30</ApsDOB>
  </AcdPriorSearches>
+ <AcdPriorSearches>
  <ApsSearchId>00rtrt000393:Ert4reN-YerteteLBM7-nhhh44f6C-jhjhjemHF4-bL1111DdTF</ApsSearchId>
  <ApsSearchPurpose>MoneyLaundering</ApsSearchPurpose>
  <ApsCompanyType>CustomerOwn</ApsCompanyType>
  <ApsUser>AccountsOnline/AccountsOnlineAPI</ApsUser>
  <ApsTitle>Mr</ApsTitle>
  <ApsForename>madeup</ApsForename>
  <ApsSurname>name</ApsSurname>
+ <ApsAddress>
  <AadBuilding>22</AadBuilding>
  <AadStreet>Test street</AadStreet>
  <AadPostTown>test town</AadPostTown>
  <AadPostcode>GU99 9AB</AadPostcode>
  </ApsAddress>
  <ApsSearchAdrMatch>Y</ApsSearchAdrMatch>
  </AcdPriorSearches>
  <AcdWarnTerrorist>N</AcdWarnTerrorist>
  <AcdWarnPolExp>N</AcdWarnPolExp>
  <AcdWarnSpecDesNat>N</AcdWarnSpecDesNat>
  <AcdWarnGoneAway>N</AcdWarnGoneAway>
  <AcdWarnPassportFraud>Y</AcdWarnPassportFraud>

Thanks
Helpful Member!jpadie (TechnicalUser)
29 Oct 09 9:59
i suspect that you are not addressing the right node.  could you post the result of this please

CODE

echo "<pre>". print_r($xmlresults, true) . "</pre>";
tsuji (TechnicalUser)
29 Oct 09 9:59
$pportfraud = (string)$xmlresults->CallResponse->AcrResponseDetail->AcdWarnPassportFraud;
$pportfraud = (string)$xmlresults->AcrResponseDetail->AcdWarnPassportFraud;

$gone = (string)$xmlresults->CallResponse->AcrResponseDetail->AcdWarnGoneAway;
$gone = (string)$xmlresults->AcrResponseDetail->AcdWarnGoneAway;
Helpful Member!jpadie (TechnicalUser)
29 Oct 09 10:05
i think you're right tsuji.  i'd prefer a hierarchical view though.
g0ker (TechnicalUser)
29 Oct 09 11:07
Hi,
having toruble with my account so had to open a new one up in the time being to reply.

Using both tsuji and jpadies code, I get :-

SimpleXMLElement Object
(
)


Both values seem to be empty cuase if I echo them, I get blanks.

Thanks
tsuji (TechnicalUser)
29 Oct 09 11:16
If you post the response exactly without anything you think you can spare, then I don't think so.
g0ker (TechnicalUser)
29 Oct 09 13:06
Sorry tsuji, I dont understand what you mean. Please can you explain a little more for me ?
tsuji (TechnicalUser)
29 Oct 09 13:29
One time you posted the $xmlResponse/$xmlresults/$xmlResults with soap envelop etc, the other time you posted without. What exactly is the response body? (Besides, I see the variables, $xmlresults, $xmlResults, $xml_document, $doc_document,... $chyType, $ChyType, $chyused, $chyUsed, $ChyUsed,... can we assume they all are used consistently behind the screen?)
tsuji (TechnicalUser)
29 Oct 09 13:56
Let me give you all the benefits of the doubt, and that it is wrapped in the soap envelop and body, do this before further elaboration.

$pportfraud = (string)$xmlresults->children("http://schemas.xmlsoap.org/soap/envelope/")->Body->children("webpage")->PerformMLCheckResponse->CallResponse->AcrResponseDetail->AcdWarnPassportFraud;
$gone = (string)$xmlresults->children("http://schemas.xmlsoap.org/soap/envelope/")->Body->children("webpage")->PerformMLCheckResponse->CallResponse->AcrResponseDetail->AcdWarnGoneAway;
Helpful Member!jpadie (TechnicalUser)
30 Oct 09 11:05
if you are using php5 then simplexml will work fine.  

you need to provide the unfiltered output of this code so that we can see the hierarchical shape of the response information

CODE

echo "<pre>". print_r($xmlresults, true) . "</pre>";
Helpful Member!jpadie (TechnicalUser)
30 Oct 09 14:02
I worked off line on this problem and tsuji chimed in (again offline) with a pointer towards the helpful asxml() method

this is a snip of the code that worked

CODE

<?php
    $results=$req->getResponseBody();
    
    //get results into an object
    libxml_use_internal_errors(true);
    $sxe = simplexml_load_string(file_get_contents($results));
    if (!$sxe) {
        echo "Failed loading XML\n";
        foreach(libxml_get_errors() as $error) {
            echo "\t", $error->message;
        }
    } else {
        $xmlResults = simplexml_load_string($sxe->asXML());
        $goneAway = trim($xml->CallResponse->AcrResponseDetail->AcdWarnGoneAway);
        $passportFraud = trim($xml->CallResponse->AcrResponseDetail->AcdWarnPassportFraud);
    }
?>
 

Start A New Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Promoting, selling, recruiting and student posting
are not allowed in the forums.
Posting Policies

LINK TO THIS FORUM!
(Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum)
TITLE: PHP Forum at Tek-Tips
URL: http://www.tek-tips.com/threadminder.cfm?pid=434
DESCRIPTION: PHP technical support forum and mutual help system for computer professionals. Selling and recruiting forbidden.

 

Back To Forum