Jump to content

Working with XML results from a URL


NickAlbert

Recommended Posts

I need to get the values from an XML result from a URL.

 

Here is what I have tried to work out after reading tutorials, but am stumped as to going further:

<?
$xmlstr = file_get_contents("https://www.site.com/checksession.asp?clientid=3915&password=byuc0913&wait=60&sessionid=8863AC8A23498DDC27993EF9F6330C50B2B4FDFE");

$reply = new SimpleXMLElement($xmlstr);

$reponse = "";
$completed = "";
$last4 = "";
$approvedamt = "";
?>

Here is the output of the URL in file_get_contents:

<?xml version="1.0" encoding="utf-8"?>
<reply>
  <response>Success</response> 
  <responsecode>0</responsecode> 
  <description>OK</description> 
  <responseurl>/soft/checksession.asp</responseurl> 
  <datablock>
		<sessionid>8863AC8A23498DDC27993EF9F6330C50B2B4FDFE</sessionid>
		<completed>yes</completed>
		<approved>Y</approved>
		<declinecount>0</declinecount>
		<gateid>76479220</gateid>
		<transtype>SALE</transtype>
		<authcode>191330</authcode>
		<avsreply>U</avsreply>
		<cvv2reply> </cvv2reply>
		<declinestr>OK</declinestr>
		<cardtype>V</cardtype>
		<cardname>Visa</cardname>
		<first6>403491</first6>
		<last4>4971</last4>
		<keyed>No</keyed>
		<expmonth>07</expmonth>
		<expyear>16</expyear>
		<approvedamt>9.67</approvedamt>
		<tip>0</tip>
		<bal></bal>
		<invoiceno>22513</invoiceno>
		<corporatecardindicator></corporatecardindicator>
		<processor_token></processor_token>
</datablock>
</reply>

Any help would be GREATLY appreciated! :)

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/279640-working-with-xml-results-from-a-url/
Share on other sites

<?

$xmlstr = file_get_contents("https://www.site.com/checksession.asp?clientid=3915&password=byuc0913&wait=60&sessionid=8863AC8A23498DDC27993EF9F6330C50B2B4FDFE");

$reply = new SimpleXMLElement($xmlstr);

echo $reply->response;
echo $reply->datablock->completed;

?>

Gave this as output:


Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 34: parser error : Opening and ending tag mismatch: meta line 15 and head in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </head> in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 37: parser error : Entity 'nbsp' not defined in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:  	</div> in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 117: parser error : Entity 'nbsp' not defined in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:  	 </div> in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 141: parser error : Opening and ending tag mismatch: br line 140 and div in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </div>	 </div> in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 141: parser error : Opening and ending tag mismatch: br line 140 and div in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </div>	 </div> in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 195: parser error : Opening and ending tag mismatch: div line 120 and body in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </body> in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 196: parser error : Opening and ending tag mismatch: div line 119 and html in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </html> in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 197: parser error : Premature end of data in tag body line 35 in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 197: parser error : Premature end of data in tag head line 3 in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 197: parser error : Premature end of data in tag html line 2 in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/tdh/public_html/network/esid/SCD_checksession.php:5 Stack trace: #0 /home/tdh/public_html/network/esid/SCD_checksession.php(5): SimpleXMLElement->__construct('??<!DOCTYPE htm...') #1 {main} thrown in /home/tdh/public_html/network/esid/SCD_checksession.php on line 5

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.