使用php解析XML文件 [英] Parsing XML file using php

查看:124
本文介绍了使用php解析XML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重新命名.这是我的代码以及XML.每次我尝试print_r响应时,它都不会反映任何内容.

Rephrase it. Here's my code together with the XML. Everytime I try to print_r the response, It does not reflect anything.

$portal   = 'CaregiverPortal';
$userName = 'dxt3uyk27U3wRRrzaFGiwQ==';
$password = 'wD81PILmPuJX2fyFek937A==';
$url      = "https://webapp.healthcaresynergy.com:8002/demoalpha/CaregiverPortalMobile/CaregiverPortalS   ervice.svc?singleWsdl";         
$option   = array('trace' => 1 ); 

$xml      = '<soapenv:Envelope   xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">'.
           '<soapenv:Header/>'.
           '<soapenv:Body>'.
              '<LoginCaregiverPortal>'.
                 '<userName>Anything</userName>'.
                 '<password>Anything</password>'.
                 '<portal>'.$portal.'</portal>'.
                 '<caregiverID>'.$userName.'</caregiverID>'.
                 '<timeStamp>'.$password.'</timeStamp>'.
              '</LoginCaregiverPortal>'.
           '</soapenv:Body>'.
         '</soapenv:Envelope>';

$client = new LocalSoapClient($url, $option, $xml);

try 
{ 
 $client->LoginCaregiverPortal();
 $response = $client->__getLastResponse(); 
 //echo 'result';
 //echo "<br/>";
 //echo htmlspecialchars($response);
 $xml = simplexml_load_string($response);
 $json = json_encode($xml);
 $array = json_decode($json,TRUE);
 print_r($array);

}

这就是我得到的结果.

Array ( )

我认为这是我得到空洞结果的地方.

I think This is where I'm getting an empty result.

 $xml = simplexml_load_string($response);
 $json = json_encode($xml);
 $array = json_decode($json,TRUE);
 print_r($array);

非常感谢您的帮助.

推荐答案

虽然很难讲很多,因为您没有提供您在程序中使用过的LocalSoapClient的代码,并且知道的不多我对Healthcaresynergy.com的要求.

While it is difficult to tell much, as you have not provided the code of LocalSoapClient that you have used in your program and there is not much known to me in terms of the requirements of healthcaresynergy.com.

但是我看到两个可能的错误.您的肥皂请求中的两行可能应该是:

However I see two probable errors. The two lines in your soap request should probably be:

'<userName>'.$userName.'</userName>'.
'<password>'.$password.'</password>'.

这篇关于使用php解析XML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆