odd IE9 with xml, php, curl - php

I have a php function that communicates with UPS using curl, xml.The script was given to me and i dont know much about it.
It works in every browser except IE9
The function returns something like this:
HTTP/1.1 200 OK Date: Tue, 06 Dec 2011 21:36:41 GMT Server: Apache
Pragma: no-cache Content-Length: 1481 X-Powered-By: Servlet/2.5
JSP/2.1 Vary: User-Agent Content-Type: application/xml
it goes on to show all the responses
from ups in xml
here is the function with the curl and xml parameters.
function ups($dest_zip,$service,$weight,$length,$width,$height) {
// This script was written by Mark Sanborn at http://www.marksanborn.net
// If this script benefits you are your business please consider a donation
// You can donate at http://www.marksanborn.net/donate.
// ========== CHANGE THESE VALUES TO MATCH YOUR OWN ===========
$AccessLicenseNumber = '000000009F002AC0'; // Your license number <br>
$UserId = '+++++'; // Username <br>
$Password = '+++++'; // Password <br>
$PostalCode = '01862'; // Zipcode you are shipping FROM <br>
$ShipperNumber = '++++'; // Your UPS shipper number <br>
// =============== DON'T CHANGE BELOW THIS LINE ===============
$data ="<?xml version=\"1.0\"?>
<AccessRequest xml:lang=\"en-US\">
<AccessLicenseNumber>$AccessLicenseNumber</AccessLicenseNumber>
<UserId>$UserId</UserId>
<Password>$Password</Password>
</AccessRequest>
<?xml version=\"1.0\"?>
<RatingServiceSelectionRequest xml:lang=\"en-US\">
<Request>
<TransactionReference>
<CustomerContext>Bare Bones Rate Request</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>Rate</RequestAction>
<RequestOption>Rate</RequestOption>
</Request>
<PickupType>
<Code>01</Code>
</PickupType>
<Shipment>
<Shipper>
<Address>
<PostalCode>$PostalCode</PostalCode>
<CountryCode>US</CountryCode>
</Address>
<ShipperNumber>$ShipperNumber</ShipperNumber>
</Shipper>
<ShipTo>
<Address>
<PostalCode>$dest_zip</PostalCode>
<CountryCode>US</CountryCode>
<ResidentialAddressIndicator/>
</Address>
</ShipTo>
<ShipFrom>
<Address>
<PostalCode>$PostalCode</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipFrom>
<Service>
<Code>$service</Code>
</Service>
<Package>
<PackagingType>
<Code>02</Code>
</PackagingType>
<Dimensions>
<UnitOfMeasurement>
<Code>IN</Code>
</UnitOfMeasurement>
<Length>$length</Length>
<Width>$width</Width>
<Height>$height</Height>
</Dimensions>
<PackageWeight>
<UnitOfMeasurement>
<Code>LBS</Code>
</UnitOfMeasurement>
<Weight>$weight</Weight>
</PackageWeight>
</Package>
</Shipment>
</RatingServiceSelectionRequest>";
$ch = curl_init("https://www.ups.com/ups.app/xml/Rate");
//curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_POST,0);
curl_setopt($ch,CURLOPT_TIMEOUT, 60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$result=curl_exec ($ch);
echo '<!-- '. $result. ' -->'; // THIS LINE IS FOR DEBUG PURPOSES ONLY-IT WILL SHOW IN HTML COMMENTS
$data = strstr($result, '<?');
$xml_parser = xml_parser_create();
xml_parse_into_struct($xml_parser, $data, $vals, $index);
xml_parser_free($xml_parser);
$params = array();
$level = array();
foreach ($vals as $xml_elem) {
if ($xml_elem['type'] == 'open') {
if (array_key_exists('attributes',$xml_elem)) {
list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']);
} else {
$level[$xml_elem['level']] = $xml_elem['tag'];
}
}
if ($xml_elem['type'] == 'complete') {
$start_level = 1;
$php_stmt = '$params';
while($start_level < $xml_elem['level']) {
$php_stmt .= '[$level['.$start_level.']]';
$start_level++;
}
//$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
if (isset($xml_elem['value'])) {
$php_stmt .= '[$xml_elem[\'tag\']] = $xml_elem[\'value\'];';
}
else {
$php_stmt .= '[$xml_elem[\'tag\']] = "";';
}
eval($php_stmt);
}
}
curl_close($ch);
return $params['RATINGSERVICESELECTIONRESPONSE']['RATEDSHIPMENT']['TOTALCHARGES']['MONETARYVALUE'];
}
The page will not render the HTML
I have no clue what I am doing. HELP!

Double check that the output of headers hasn't been enabled
curl_setopt($curl_handle, CURLOPT_HEADER,1);
Comment out that line or set it to false.

Related

MWS Feeds Update Quantities in php - Amazon

it's a few days that I am trying to update the quantity of inventory on Amazon through php and Amazon MWS in php (without using MWS APIs because in my opinion are out of dated)
Here is my code:
$param = array();
$param['AWSAccessKeyId'] = $this->CHIAVE_ACCESSO;
$param['Action'] = 'SubmitFeed';
$param['Merchant'] = $this->SELLER_ID;
$param['FeedType'] = '_POST_INVENTORY_AVAILABILITY_DATA_';
$param['SignatureMethod'] = 'HmacSHA256';
$param['SignatureVersion'] = '2';
$param['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
$param['Version'] = '2009-01-01';
$params['MarketplaceId.Id.1'] = $this->MARCKETPLACE_IT;
$params['MarketplaceId.Id.2'] = $this->MARCKETPLACE_UK;
$params['MarketplaceId.Id.3'] = $this->MARCKETPLACE_ES;
$params['MarketplaceId.Id.4'] = $this->MARCKETPLACE_DE;
$params['MarketplaceId.Id.5'] = $this->MARCKETPLACE_FR;
$param['PurgeAndReplace'] = 'false';
foreach ($param as $key => $val) {
$key = str_replace("%7E", "~", rawurlencode($key));
$val = str_replace("%7E", "~", rawurlencode($val));
$url[] = "{$key}={$val}";
}
$amazon_feed = '<?xml version="1.0" encoding="utf-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>' .$this->SELLER_ID. '</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>'.$sku.'</SKU>
<Quantity>'.$qty.'</Quantity>
</Inventory>
</Message>
</AmazonEnvelope>';
sort($url);
$arr = implode('&', $url);
$sign = 'POST' . "\n";
$sign .= 'mws.amazonservices.it' . "\n";
$sign .= '/Feeds/'.$param['Version'].'' . "\n";
$sign .= $arr;
$signature = hash_hmac("sha256", $sign, $this->secretKey, true);
$httpHeader = array();
$httpHeader[] = 'Transfer-Encoding: chunked';
$httpHeader[] = 'Content-Type: application/xml';
$httpHeader[] = 'Content-MD5: ' . base64_encode(md5($amazon_feed, true));
//$httpHeader[] = 'x-amazon-user-agent: MyScriptName/1.0';
$httpHeader[] = 'Expect:';
$httpHeader[] = 'Accept:';
$signature = urlencode(base64_encode($signature));
$link = "https://mws.amazonservices.it/Feeds/".$param['Version']."?";
$link .= $arr . "&Signature=" . $signature;
echo $link;
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $amazon_feed);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$errors=curl_error($ch);
curl_close($ch);
echo '<pre>';
print_r($response); //xml response
The response is
50691017150_POST_INVENTORY_AVAILABILITY_DATA_2016-12-15T10:00:09+00:00_SUBMITTED_47843855-c5fb-4db9-bc3c-1ccd0aff4169
But When I go on the Amazon Inventory I cannot see any changes. I've tried also to wait some days but nothing changes.
What I'm doing wrong?
Thanks in advance for help!
Using MWS Scratchpad the error I have is the following
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.02</DocumentVersion>
<MerchantIdentifier>A2PDC8GCZHAL2D</MerchantIdentifier>
</Header>
<MessageType>ProcessingReport</MessageType>
<Message>
<MessageID>1</MessageID>
<ProcessingReport>
<DocumentTransactionID>50691017150</DocumentTransactionID>
<StatusCode>Complete</StatusCode>
<ProcessingSummary>
<MessagesProcessed>1</MessagesProcessed>
<MessagesSuccessful>0</MessagesSuccessful>
<MessagesWithError>1</MessagesWithError>
<MessagesWithWarning>0</MessagesWithWarning>
</ProcessingSummary>
<Result>
<MessageID>1</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>13013</ResultMessageCode>
<ResultDescription>This SKU does not exist in the Amazon.com catalog. Your inventory data was not processed. For reasons why, and help fixing this, see http://sellercentral.amazon.it/gp/errorcode/13013</ResultDescription>
<AdditionalInfo>
<SKU>887235757035</SKU>
</AdditionalInfo>
</Result>
</ProcessingReport>
</Message>
but this sku exists in my catalog
The actual response is alway XML from MWS, where you can see that 50691017150 is actually your FeedSubmissionId.
When you submit a feed MWS gives you back with a FeedSubmissionId, by which you can track what happened to your feed.
If you go to MWS Scratchpad, you can get the feed result.
Enter the required credentials in Authentication form and select feed as Sezione AP and GetFeedSubmissionResult as Operation.
You will be than asked for FeedSubmissionId which you already have.
See what happened to that feed and why did it fail?
You are passing Marketplace Ids , which means that the sku is available there. But in your case it might not be available in any one of these. And MarketplaceId is optional, you can remove
$params['MarketplaceId.Id.1'] = $this->MARCKETPLACE_IT;
$params['MarketplaceId.Id.2'] = $this->MARCKETPLACE_UK;
$params['MarketplaceId.Id.3'] = $this->MARCKETPLACE_ES;
$params['MarketplaceId.Id.4'] = $this->MARCKETPLACE_DE;
$params['MarketplaceId.Id.5'] = $this->MARCKETPLACE_FR;

Error is parsing the XML in PHP with simplexml

My XML to be parsed is in this format:
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header />
<env:Body>
<n0:ZFM_PAYSLIP1Response xmlns:n0="urn:sap-com:document:sap:rfc:functions">
<LS_EMP_PAYSLIP_DATA>
<ZEMP_NO>00199999</ZEMP_NO>
<ZEMP_NAME>AJ KUMAR</ZEMP_NAME>
<ZSAL_MONTH>JUL-2016</ZSAL_MONTH>
<ZBASIC_PAY>57240.0</ZBASIC_PAY>
<ZGROSS_PAY>145062.29</ZGROSS_PAY>
<ZNET_PAY>50728.0</ZNET_PAY>
<ZINCOME_TAX>25858.0</ZINCOME_TAX>
<ZLEAVE_ENCASH>0.0</ZLEAVE_ENCASH>
<ZDUTY_PAY>41976.0</ZDUTY_PAY>
<ZDA>56950.4</ZDA>
<ZPERKS>26330.4</ZPERKS>
<ZHRA>11448.0</ZHRA>
<ZTOT_DEDUCTIONS>94334.29</ZTOT_DEDUCTIONS>
<ZCPF>12787.0</ZCPF>
<ZVPF>50000.0</ZVPF>
<ZLIC>0.0</ZLIC>
<ZTHRIFT_FUND>0.0</ZTHRIFT_FUND>
<ZGRP_INS>160.0</ZGRP_INS>
<ZPROF_TAX>200.0</ZPROF_TAX>
<ZDUTY_DAYS>18</ZDUTY_DAYS>
<ZWEEK_OFF>4</ZWEEK_OFF>
<ZFL />
<ZCL />
<ZEL />
<ZFPL />
<ZHPL>8</ZHPL>
<ZCML />
<ZEOL />
<ZUAB />
<ZDEISGNATION>Sr.Manager(IT)</ZDEISGNATION>
<ZDEPT_CODE>03007900</ZDEPT_CODE>
<ZCL_BAL>3</ZCL_BAL>
<ZEL_BAL>270.5</ZEL_BAL>
<ZHPL_BAL>180</ZHPL_BAL>
</LS_EMP_PAYSLIP_DATA>
</n0:ZFM_PAYSLIP1Response>
</env:Body> </env:Envelope>
I am using PHP curl to get data from remote with
this PHP code :
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://hostanme.tld/ERP_PAY_XML.xml');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
//echo $result;
curl_close($ch);
$xml = simplexml_load_string($result);
$ns = $xml->getNamespaces(true);
$soap = $xml->children($ns['env']);
echo "<br> len-soap : " . $soap;
$getaddressresponse = $soap->Body->children($ns['n0']);
foreach ($getaddressresponse->getLocationForGroupResponse->children($ns['n0']) as $item)
{
$item = $item->children();
echo $item->address . '<br />';
}
?>
but still I am not getting any result. Anybody please help..
Is there any other way to parse XML to an object..

Amazon MWS - Update product quantity

I am using amazon api for update product's quantity using "_POST_INVENTORY_AVAILABILITY_DATA_" feedtype like,
<?xml version="1.0" encoding="utf-8" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>$merchantID</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>$SKU</SKU>
<Quantity>8</Quantity>
</Inventory>
</Message>
</AmazonEnvelope>
<?xml version="1.0"?>
<SubmitFeedResponse xmlns="http://mws.amazonaws.com/doc/2009-01-01/">
<SubmitFeedResult>
<FeedSubmissionInfo>
<FeedSubmissionId>6791310806</FeedSubmissionId>
<FeedType>_POST_INVENTORY_AVAILABILITY_DATA_</FeedType>
<SubmittedDate>2013-03-21T19:48:37+00:00</SubmittedDate>
<FeedProcessingStatus>_SUBMITTED_</FeedProcessingStatus>
</FeedSubmissionInfo>
</SubmitFeedResult>
<ResponseMetadata>
<RequestId>fd07bf18-4f6a-4786-bdf9-9d4db50956d0</RequestId>
</ResponseMetadata>
</SubmitFeedResponse>
but when i try to update 15k or more products at a time by loading products using magento collection quantity not updating in amazon after few hours also. Is it right method or do i need to use any other method?
Can anyone help me?
Thanks in advance.
Try Using _POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA_ feedtype and send a CSV file (tab delimited) in the body of the https request instead of an XML file. The first line of the csv should be: sku price quantity (separated by tabs) followed by lines containing the values (separated by tabs).
Quoting Amazon MWS API:
Feed size is limited to 2,147,483,647 bytes (2^31 -1) per feed. If you
have a large amount of data to submit, you should submit feeds smaller
than the feed size limit by breaking up the data, or submit the feeds
over a period of time. One good practice is to submit feeds with a
size limit of 30,000 records/items or submit feeds over a period of
time, such as every few hours.
$feed = '<?xml version="1.0" encoding="utf-8" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>AG7AH5X9UOHEC</MerchantIdentifier>
</Header>
<MessageType>Inventory</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>UK-BBD10002</SKU>
<Quantity>4</Quantity>
<FulfillmentLatency>15</FulfillmentLatency>
</Inventory>
</Message>
<Message>
<MessageID>2</MessageID>
<OperationType>Update</OperationType>
<Inventory>
<SKU>UK-BBD10003</SKU>
<Quantity>6</Quantity>
<FulfillmentLatency>14</FulfillmentLatency>
</Inventory>
</Message>
</AmazonEnvelope>';
$feedHandle = #fopen('php://temp', 'rw+');
fwrite($feedHandle, $feed);
rewind($feedHandle);
$param['AWSAccessKeyId'] = Configure::read('AWS_ACCESS_KEY');
$param['Action'] = 'SubmitFeed';
$param['SellerId'] = Configure::read('SELLER_ID');
$param['SignatureMethod'] = Configure::read('SIGNATURE_METHOD');
$param['SignatureVersion'] = Configure::read('SIGNATURE_VERSION');
$param['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
$param['Version'] = '2009-01-01';
$param['FeedType'] = $FeedType;
$param['FeedContent'] = stream_get_contents($feedHandle);
$param['ContentMd5'] = base64_encode(md5(stream_get_contents($feedHandle), true));
$param['MarketplaceIdList.Id.1'] = $MARKETPLACE_ID; //FR
//$param['MarketplaceIdList.Id.2'] = 'A1F83G8C2ARO7P'; //GB
ksort($param);
$MARKETPLACE_URL = 'mws.amazonservices.co.uk';
$secret = Configure::read('SECRET_KEY');
$url = array();
foreach ($param as $key => $val) {
$key = str_replace("%7E", "~", rawurlencode($key));
$val = str_replace("%7E", "~", rawurlencode($val));
$url[] = "{$key}={$val}";
}
ksort($url);
$arr = implode('&', $url);
$sign = 'GET' . "\n";
$sign .= ''.$MARKETPLACE_URL.'' . "\n";
$sign .= '/Feeds/2009-01-01' . "\n";
$sign .= $arr;
$signature = hash_hmac("sha256", $sign, $secret, true);
$signature = urlencode(base64_encode($signature));
$link = "https://".$MARKETPLACE_URL."/Feeds/2009-01-01?";
$link .= $arr . "&Signature=" . $signature;
$httpHeader = array();
$httpHeader[] = 'Content-Type: application/xml';
$httpHeader[] = 'Content-MD5: ' . base64_encode(md5(stream_get_contents($feedHandle), true));
$httpHeader[] = 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'];
$httpHeader[] = 'Host: ' . $MARKETPLACE_URL;
ksort($httpHeader);
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
#fclose($feedHandle);
print_r($response);
exit;

php process xml into array

I'm tring to process xml (website) into php array.
I have tried the following code which works for everyting in results but i need to get the totalpage which i'm not able to see how I can do this.
function get_content($url)
/// basically opens the page and stores it as a variable. Buggered if I know how it works!
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
ob_start();
curl_exec ($ch);
curl_close ($ch);
$string = ob_get_contents();
ob_end_clean();
return $string;
$string = NULL;
$ch = NULL;
$url = NULL;
}
$url = "url";
$content = get_content($url);
$content_x = explode("<result>", $content);
foreach ($content_x as $item)
{
$p1 = strpos($item, '<title>');
$p2 = strpos($item, '</title>');
$l1 = $p2 - $p1;
echo '<br>'.$title = substr($item, $p1, $l1);
}
xml site feed
<?xml version="1.0" encoding="UTF-8"?>
<response version="2">
<totalpage>1005</totalpage>
<results>
<result>
<title>test</title>
<title2>test2</title2>
<title3>test3</title3>
<result>
<result>
<title>test</title>
<title2>test2</title2>
<title3>test3</title3>
<result>
<result>
<title>test</title>
<title2>test2</title2>
<title3>test3</title3>
<result>
........so on
<results>
</response>
I need to get totalpage and everyting in results
How do get totalpage and is they better way to process the results
You absolutely should not be using string manipulation to try to parse XML. There are any number of PHP libraries that can do this. I might recommend SimpleXML.
Usage would be:
$xml = simplexml_load_string($content);
$totalpage = $xml->response->totalpage;

php parse xml to array for same level same name keys

I've tried many pre built parsers including the xml2array parser with no luck. I've also tried my own without any success either. I've tried simplexmlelement/xpath and a bunch of different ways with the same result so I'm at a place where I'm banging my head on my keyboard.
Basically I'm trying to parse code the API call is spitting back to me. I'm making a soap call and getting the xml content via curl (https).
Here is an example of the xml I'm getting back:
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Content-Type: text/xml;charset=UTF-8
Transfer-Encoding: chunked
Date: Sat, 21 Apr 2012 19:49:30 GMT
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Header></env:Header>
<env:Body>
<ns:processRequestResponse xmlns:ns='hidden.address'>
<result>
<?xml version="1.0" encoding="UTF-8"?>
<CRMMessage language="en_US" currency="USD" isTrustedSAT="false" hostversion="hiddenINT">
<RequestCode>HiddenMethoForCall</RequestCode>
<ResponseCode>A</ResponseCode>
<ResultSet>
<ResultSetMetaData>
<RSColumn name="FirstName" type="string" nullable="true"></RSColumn>
<RSColumn name="LastName" type="string" nullable="true"></RSColumn>
<RSColumn name="EmailAddress" type="string" nullable="true"></RSColumn>
</ResultSetMetaData>
<Rows>
<Row id="hiddenINT">
<Col>John</Col>
<Col>Doe</Col>
<Col>john#doe.com</Col>
</Row>
</Rows>
</ResultSet>
</CRMMessage>
</result>
</ns:processRequestResponse>
</env:Body>
</env:Envelope>
I tried using xml2array, but that explicitly states that it doesn't support parsing same name keys in the same level.
I'm not sure if it will matter, as I'm open to any parsers suggested, but here is one that I put together (this is inside the class that handles the request after the request is made):
$retVal = curl_exec($soap_do);
if($retVal === false) {
$err = 'Curl error: ' . curl_error($soap_do);
throw new requestManager($err);
} else {
$string = strstr($retVal, '<');
// $aResp = simplexml_load_string($string);
if(!function_exists('xml_parser_create')) {
//print "'xml_parser_create()' function not found!";
return array();
}
curl_close($soap_do);
//custom parse
$aResp = array();
$i=0;
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
// xml_parse_into_struct($parser, $string, $values, $tags);
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
xml_parse_into_struct($parser, trim($string), $values);
xml_parser_free($parser);
// var_dump($values);
foreach($values as $val) {
foreach($val as $key=>$value) {
if($key=='value'){
if(is_array($value)) {
foreach($value as $k=>$v) {
echo $v;
$value[$i]=$value;
}
}else {
$aResp[$i]=$value;
echo '<h1>'.$key.'</h1>';
echo '<h2>'.$value.'</h2><br>';
}
$i++;
}
}
}
}
Any help would be appreciated as I'm hitting a wall here. I've checked every resource I can think of with no luck. Thank you!

Categories